Generate e-mail message for Outlook with BCC filled in

痞子三分冷 提交于 2019-12-12 03:28:14

问题


I'm trying to generate an e-mail draft which will be opened by Outlook (so that the user can make changes before actually sending). I'm using PHPMailer and everything works: encoding, attachments, everything - except BCC field.

<?php
// non-essential stuff omitted
$mail = new PhpMailer();
$mail->CharSet = 'UTF-8';
$body = '<html><body><p>does not matter</p></body></html>';
// set To:
foreach ($contacts as $address) {
    if ($this->looksLikeEmail($address)) {
        $mail->addAddress($address);
    }
}

// set CC:
$businessContacts = $this->loadCcEmails();
foreach ($businessmenContacts as $address) {
    if ($this->looksLikeEmail($address)) {
        $mail->addCC($address);
    }
}

// set BCC:
$mail->addBCC($this->bccAddress);
$mail->Body = $body;
// generate MIME headers and body
$mail->preSend();

// do not send - get the mail as a string
$emailFull = $mail->MIMEHeader . $mail->LE . $mail->MIMEBody;

// send to browser
header('Content-Description: File Transfer');
// handled by default e-mail client
header('Content-Type: message/rfc822');
header('Content-Disposition: inline; filename="template.eml"');
header('Cache-Control: private');
header('Content-Length: ' . strlen($emailFull));

echo $emailFull;
exit;

I'm adding the BCC field as usual, and it is present in the template.eml file generated by PHP:

Date: Thu, 2 Jun 2016 10:53:35 +0200
To: foo@example.com
Cc: bar@example.com
Bcc: baz@example.com
Subject: =?UTF-8?Q?TESTOVAC=C3=8D?=
Message-ID: <f2693cd5b0b081a75408beef87bfc651@localizer>
X-Unsent: 1
MIME-Version: 1.0
Content-Type: multipart/alternative;
    boundary="b1_f2693cd5b0b081a75408979287bfc651"
Content-Transfer-Encoding: 8bit

etc.

However, when opened in Outlook 2010, the BCC field is not filled at all; when the same file is opened in Thunderbird, BCC is filled in. Is there a way to force Outlook to pre-fill the BCC in draft without directly automating Outlook (I don't have control over the users' computers, only of the server)?

来源:https://stackoverflow.com/questions/37587397/generate-e-mail-message-for-outlook-with-bcc-filled-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!