Trying to process inbound mails that are bcc'd to [email protected] (Office 365).

Pasting the code we have at https://github.com/civicrm/civicrm-core/blob/master/CRM/Mailing/MailStore.php#L128-L138

$parser = new ezcMailParser();
//set property text attachment as file CRM-5408
$parser->options->parseTextAttachmentsAsFiles = TRUE;
foreach ($set->getMessageNumbers() as $nr) {
  if ($this->_debug) {
    print "retrieving message $nr\n";
  $single = $parser->parseMail($this->_transport->fetchByMessageNr($nr));
  $mails[$nr] = $single[0];

When a mail is bcc'd from a Gmail account to [email protected] and Process Inbound Email job is executed, $mails correctly contain the email address in the bcc header.

But, when it is sent from an outlook account or Apple Mail, there is no bcc or any header that contains an information that our mail was bcc'd to [email protected].

Does our email parser strips bcc information if the input is from a server other than Gmail?

Update -

If mail is sent from Gmail, headers look like - https://gist.github.com/jitendrapurohit/fa6a115c18b8bcfbb8346f58cd1265c0

From Outlook - https://gist.github.com/jitendrapurohit/176eee759cfc9b3688682ea99b6c3460

  • I would recommend forwarding the email to a separate (non-Civi) address from both GMail and Apple Mail and examining the headers. Post the relevant headers on this question if necessary. I suspect you'll find a difference in the headers that causes different behavior. Commented Feb 5, 2018 at 16:29
  • yes, there is a difference and it doesn't include bcc info - I'll update the same on the question Commented Feb 6, 2018 at 2:37

1 Answer 1


In my experience, reading the Bcc field is not a reliable source of information, because there is not always available data. Thanks to your question I checked the RFC in response to your question and learned why!

What's happening

See https://www.rfc-editor.org/rfc/rfc2822#page-22

The "Bcc:" field (where the "Bcc" means "Blind Carbon Copy") contains addresses of recipients of the message whose addresses are not to be revealed to other recipients of the message. There are three ways in which the "Bcc:" field is used.

In the first case, when a message containing a "Bcc:" field is prepared to be sent, the "Bcc:" line is removed even though all of the recipients (including those specified in the "Bcc:" field) are sent a copy of the message.

When sender and recipient are on different servers, this is the behaviour you'll observe. (Outlook.com => Gmail.com result)

In the second case, recipients specified in the "To:" and "Cc:" lines each are sent a copy of the message with the "Bcc:" line removed as above, but the recipients on the "Bcc:" line get a separate copy of the message containing a "Bcc:" line.

(When there are multiple recipient addresses in the "Bcc:" field, some implementations actually send a separate copy of the message to each recipient with a "Bcc:" containing only the address of that particular recipient.)

When sender and recipient are on Outlook.com, this is the behaviour you observe. (Outlook.com => Outlook.com result)

Finally, since a "Bcc:" field may contain no addresses, a "Bcc:" field can be sent without any addresses indicating to the recipients that blind copies were sent to someone.

So - it's not a difference in Outlook vs GMail behaviour, so much as a difference in how MTAs handle internal and external deliveries. I still would not expect to see other Bcc recipients appear though.

See also this similar question/answer.

How to handle this

My take is: if you're parsing an email and the receiving address is not in To or Cc, it’s a fair bet that it was either Bcc'd or the receiving address is the final recipient of an email alias.

Beyond that, don’t expect to know who’s in the Bcc field - that’s what it’s for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.