【发布时间】:2014-07-31 16:06:58
【问题描述】:
我正在使用以下代码使用 IMAP_APPEND 在已发送文件夹中的邮件消息中添加多个附件。在已发送的文件夹中,我只收到一个附件,没有其他附件。任何人都可以建议这是什么问题吗??
if ($mbox=imap_open( $authhost, $user, $pass))
{
$dmy=date("d-M-Y H:i:s");
$boundary = "------=" . md5(uniqid(rand()));
$msg .= "From: ".$from[0]."\r\n"
. "To: ".$recipients[$key][0]."\r\n"
. "CC: ".$ccList."\r\n"
. "Date: $dmy\r\n"
. "Subject: $subject\r\n"
. "MIME-Version: 1.0\r\n"
. "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n"
. "\r\n\r\n"
. "--$boundary\r\n"
. "Content-Type: text/html;\r\n\tcharset=\"ISO-8859-1\"\r\n"
. "Content-Transfer-Encoding: 8bit \r\n"
. "\r\n\r\n"
. $body . "\r\n"
. "\r\n\r\n"
. "--$boundary\r\n"
. "Content-Transfer-Encoding: base64\r\n";
foreach($attachment as $attchURL){
$files = $_SERVER['DOCUMENT_ROOT'] . "/attachments/" . $attchURL;
$filename = substr($attchURL, strrpos($attchURL,"/")+1);
$ouv=fopen ("$files", "rb");$lir=fread ($ouv, filesize ("$files"));
fclose($ouv);
$attachments = chunk_split(base64_encode($lir));
$msg .= "Content-Disposition: attachment; filename=\"$filename\"\r\n" ;
$msg .= "\r\n" . $attachments . "\r\n";
}
$msg .= "\r\n\r\n\r\n"
. "--$boundary--\r\n\r\n";
imap_append($mbox,$authhost,($msg));
imap_close($mbox);
}
【问题讨论】: