PHP Classes

Empty headers issue

Recommend this page to a friend!

      MIME E-mail message sending  >  All threads  >  Empty headers issue  >  (Un) Subscribe thread alerts  
Subject:Empty headers issue
Summary:Empty headers causing problems
Messages:5
Author:Vlad
Date:2011-11-28 00:58:26
Update:2011-11-28 04:23:03
 

 


  1. Empty headers issue   Reply   Report abuse  
Picture of Vlad Vlad - 2011-11-28 00:58:26
From what I can tell, the headers "To" and "Subject" are not mandatory. They however have defined values (of "") inside the "email_message_class" class.
When you are sending a message to many BCC recipients, you don't really want to define a "To" field as that would confuse the recipients. If you do not defined a value, the class will use the empty string, which will cause an empty new line to be added in the message's header. This will cause the e-mail clients to dump the message's source for the readers, as they will think that the new line represents the ends of the headers list.
It took some time to trace this problem, so I hope it helps others who are bothered by it.

Thanks Manuel for a wonderful class!

  2. Re: Empty headers issue   Reply   Report abuse  
Picture of Vlad Vlad - 2011-11-28 01:00:40 - In reply to message 1 from Vlad
Actually, I think the problem lies with the "email_message_class::FormatHeader" function, which strips any headers with empty strings as values. I consider it a bug.

  3. Re: Empty headers issue   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2011-11-28 01:30:28 - In reply to message 1 from Vlad
I don't know where have you seen that To and Subject headers are not mandatory, but the PHP mail() functions has mandatory $to and $subject parameters, so something needs to be passed to it.

  4. Re: Empty headers issue   Reply   Report abuse  
Picture of Vlad Vlad - 2011-11-28 02:17:13 - In reply to message 3 from Manuel Lemos
I am referring to the SMTP protocol. I don't use PHP's built-in function. From my perspective this issue is limited to the "smtp_message_class".

  5. Re: Empty headers issue   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2011-11-28 04:23:03 - In reply to message 4 from Vlad
Yes, but the base class uses the mail function and sub-classes implement the same function calls.

Still the RFC 822 states that To: header is mandatory. SMTP protocol does not say anything message contents.