我正在尝试生成一个将由Outlook打开的电子邮件草稿(以便用户可以在实际发送之前进行更改)。我正在使用PHPMailer,一切正常:编码,附件,一切 - 除了BCC字段。
<?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;
我像往常一样添加BCC字段,它存在于PHP生成的template.eml
文件中:
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
等。
但是,在Outlook 2010中打开时,BCC字段根本没有填充;当在Thunderbird中打开同一个文件时,BCC会被填入。有没有办法强制Outlook在没有directly automating Outlook的情况下预先填写BCC草稿(我无法控制用户的计算机,只有服务器)?