Microsoft Graph Bcc not working
-
FluentSMTP resets PHPMailer to “mail” mode, not SMTP mode, before every send — see helpers.php:639 (
$phpmailer->isMail()), and no code path in the Outlook provider ever callsisSMTP()(onlyProviders\Smtp\Handler.php:45does that, for the plain-SMTP connection type).That mode matters a lot for Bcc. PHPMailer only omits the
Bcc:header from the generated MIME whenMailer === 'smtp'(because in real SMTP mode it delivers Bcc via an extra invisibleRCPT TOcommand instead). Since Outlook’s mode is'mail', PHPMailer does write aBcc:header into the raw MIME — so at the PHP level, Bcc is present, right alongside Cc.But the Outlook handler throws that context away. Outlook/Handler.php:77-102 (
sendViaApi()) just grabs$this->phpMailer->getSentMIMEMessage(), base64-encodes it, and POSTs the raw MIME blob tohttps://graph.microsoft.com/v1.0/me/sendMail(Outlook/API.php:133-142) withContent-Type: text/plain. That’s it — no structured JSON recipients are sent.Microsoft Graph’s raw-MIME ingestion at
/me/sendMailparsesTo:andCc:out of the header block fine, but doesn’t route delivery off aBcc:header found in raw MIME content. It only honors Bcc when it’s supplied as a structuredbccRecipientsfield. This is a known Graph API quirk with the “upload raw MIME” send path — not something this plugin’s header-building is getting wrong.Proof it’s architectural, not accidental: other providers in this same FluentSMTP install handle Bcc correctly because they don’t use the raw-MIME path.
BaseHandler::setAttributes()(around BaseHandler.php:186-206) already extractsgetBccAddresses()into$attributes['headers']['bcc']for every provider — and Mailgun’s handler actually uses it (Mailgun/Handler.php:65,152), building its ownbccfield in its API call. The Outlook handler is the one provider that ignores this pre-computed data entirely.Ways to actually fix it (not applying any of these yet):
Best fix — change
Outlook\Handler::sendViaApi()to stop using the raw-MIME/sendMailendpoint, and instead build the structured Graph JSON payload (message.toRecipients/ccRecipients/bccRecipients), pulling bcc from theheaders.bccarrayBaseHandleralready computes — mirroring what Mailgun’s handler does today.
You must be logged in to reply to this topic.