Mail() is eating my bcc: header

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Dear all

I have a script (below) that for a long time has been sending out to an  
opt-in distribution list, about 100 members. Today it has stopped working  
and I am not quite sure what I have changed. This is the smallest version  
that still demonstrates the problem (addresses obviously changed from the  
real ones):

  $subject = 'Small test';

  $sender = '';

  $contents = "This is a short test message";

  $recips  = "";
  $recips .= ",\r\n";
  $recips .= ",\r\n";
  $recips .= ",\r\n";

  $header='From: ' . $sender . "\r\nX-mailer: php mail()" .  
        "\r\nbcc: " . $recips;

  echo("<h4>Header string:</h4><pre>$header</pre>");

  $success = mail($sender, $subject, $contents, $header);

The symptom is that the entire "bcc:" line disappears,  
leaving the other three addresses tacked onto the X-mailer header. Prior  
to putting in that dummy line, they were attached to the To: header,  
which is not much use.  

If I change the Bcc: to cc: (i.e. remove just one character) then it  
formats and sends perfectly as expected -- but of course, all the  
addresses are visible.

I don't think it is the ISP (Linux, shared web hosting) because it  
happens on my own Windows test server. Looking at my server's firewall  
log, the mangling has already happened on the way out to the smtp server.  

I have tried all the ways I can think of to create the $header string,  
but all with the same outcome. There is no function or variable called  
Bcc that could be causing substituting.  

I can't think of anything I've done. Help please?

Tim F

Re: Mail() is eating my bcc: header

Quoted text here. Click to load it

Have you also tried to make a simple test header string without any string  
concanations and variables?
Because often we can be so sure, that our variable is something that it is  

Options imho:

a) your string is not want you think it is
b) the way you believe that string should be build for mail()-function is  
c) more mysterious server reason

Re: Mail() is eating my bcc: header

Quoted text here. Click to load it

Yes: I can send it with all the bcc addresses on a single line and it goes  
out correctly to all four addresses.  

Quoted text here. Click to load it

That is the reason for the echo("<pre>$header</pre>"); line.  
Quoted text here. Click to load it

Possible, but I can't see what else it could be.  

Quoted text here. Click to load it

As far as I can tell, it's RFC conformant. There is no way I can put all  
100 addresses on one line.  

Quoted text here. Click to load it

My server reports that this one file is encoded as UTF-8 rather than ISO-
8859-1 (which all the other pages on the same site are) but I don't know if  
I am now chasing ghosts.

Thanks anyway

Tim F

Site Timeline