2

Not sure if this belongs here or not, as I am the one generating the email via PHP.

Basically, using the code below, when anyone in the BCC views the email (at least in gmail where I checked), the BCC recipients can all see each other, see screenshot. BCC Shows a list of recipients

Have any of you seen this behaviour before? I have run the same code on a different server with the same hosting company and it works as expected. Not sure if it is because on the server I am having issues on it has an external mail server set up. I have also tried with PHPMailer and had the same issue.

I have left the 'mailed-by' portion in the image in case something can be found from that.

Here is the code I am using to send the email.

$subject = "BCC Not Working as Expected...";
$body = "BCC Not Working as Expected...";

$headers = [];
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/html; charset=iso-8859-1";
$headers[] = "From: Example <info@example.com>";
$headers[] = "To: Some Person <someperson@example.com>";
$headers[] = "Bcc: John <johnwales.jw@gmail.com>, Paul <paul@example.com>, Ringo <ringo@example.com>, George <george@example.com>";

mail(null, $subject, $body, implode("\r\n", $headers));

echo implode("\r\n", $headers);
// Output:
// MIME-Version: 1.0 Content-type: text/html; charset=iso-8859-1 From: Example To: Some Person Bcc: John , Paul , Ringo , George
johnsnails
  • 1,971
  • 20
  • 29
  • 1
    Hmm, this should work as you've done it. Which users are you checking Gmail accounts for? You've probably seen this advice before, but it is very highly recommended to use something like [PHPMailer](https://github.com/PHPMailer/PHPMailer) these days, instead of manually building up messages using `mail()`. It's much easier to get right and to debug when it goes wrong. – Michael Berkowski Jul 20 '15 at 23:35
  • The emails in the BCC were gmail, google apps and exchange accounts. All could see each other. yes I first noticed while using PHPMailer, I switched to the mail function to try fix. Have you ever seen something like this before? I've narrowed it down to happening on one server by the hosting company, we host multiple sites on this particular IP and I noticed it after we move up to a new plan. If I use that script via one of their other servers it works as expected but they think it is my issue. I should point out, i have always had the best experience with them and this is not a go at them. – johnsnails Jul 20 '15 at 23:47
  • Hmm, that's really suspicious that it occurs on just one server. Can you verify that Bcc behaves correctly when you just send a regular email from a client to entirely rule out your software? – Michael Berkowski Jul 21 '15 at 00:00
  • I think I can rule out software. We host about 5 websites on this particular IP. 4 of them use external mail servers and one just uses the webmail on the server itself. Ive tried sending email from ones that have external mail servers and ones that don't, same bcc issue. Its only when I try my personal website (which happens to be with the same hosting company, but on a different IP) that I can get normal BCC behaviour. Maybe I should link to this article on their ticketing system see if they are more interested. Do you think any combination of mx, spf or email authentication could contribute? – johnsnails Jul 21 '15 at 00:14
  • There could be something strangely configured with the MTA on that server. – Michael Berkowski Jul 21 '15 at 00:21
  • Good point, just found this, I might ask them to take a look. http://superuser.com/questions/345285/is-bccing-e-mails-guaranteed-to-be-reliable – johnsnails Jul 21 '15 at 00:26

1 Answers1

1

This is not something I've seen before, and your implementation looks fine. The recipient of an email can normally see any email address specified by the Sender in the To or Cc fields. If the Sender has specified addresses in the Bcc field, the recipient cannot normally see these. Having said that, some doubt exists about the exact intent of the Bcc field, so there are no guarantees. Please see this article on Wikipedia for more information.

Cheers

ritter
  • 555
  • 4
  • 13
  • Interesting about BCC, didn't realise that it is unclear how software may or may not be able to show them. I wonder if depending on how the server sends the mail determines if the end software can or cannot see the list. – johnsnails Jul 20 '15 at 23:50
  • I think the posts in this [question](http://stackoverflow.com/questions/2750211/sending-bcc-emails-using-a-smtp-server) do a good job of answering it in depth. – ritter Jul 21 '15 at 00:38