我正在尝试使用php的imap_append函数将电子邮件复制到我发送的文件夹中。它在没有附件的电子邮件上完美运行。但是,如果我添加一个附件,它似乎会出现错误:
Notice: Unknown: [CLOSED] IMAP connection broken (server response) (errflg=2) in Unknown
奇怪的是,如果我附上带有几行的.txt文件,附件就会通过,但是如果我附上一个pdf / word文档/ etc,它会发出上述错误。
我已经检查了标题/正文/附件,但据我所知,所有内容似乎都很好。我使用的是PHPMailer第5版。
下面的PHP代码:
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->Host = "smtp.livemail.co.uk";
$mail->Username = "xxx@xxx.com";
$mail->Password = "xxx";
$mail->CharSet = "UTF-8";
$mail->From = "xxx@xxx.co.uk";
$mail->FromName = "Test";
$mail->Subject = "Testing";
$mail->AltBody = "Testing";
$mail->MsgHTML("<body><h1>Hello, this is a test</h1></body>");
$mail->AddAddress("xxx@xxx.co.uk", "xxx");
$mail->AddAttachment("attachment.docx");
$mail->Send();
// We would like to append message into our sent folder at this point
$connection_string = "{mail.livemail.co.uk:993/imap/ssl}Sent Items";
$stream = imap_open($connection_string, "xxx@xxx.co.uk", "xxx");
imap_append($stream,$connection_string,$mail->CreateHeader() . $mail->CreateBody());
接头
Date: Thu, 16 Nov 2017 19:30:43 +0000
Return-Path: xxx@xxx.co.uk
To: xxx <xxx@xxx.co.uk>
From: xxx <xxx@xxx.co.uk>
Subject: Testing
Message-ID: <e92d6eed5e3b708416fb06661aeaab2c@localhost>
X-Priority: 3
X-Mailer: PHPMailer 5.1 (phpmailer.sourceforge.net)
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="b1_e92d6eed5e3b708416fb06661aeaab2c"
--b1_e92d6eed5e3b708416fb06661aeaab2c
Content-Type: multipart/alternative;
boundary="b2_e92d6eed5e3b708416fb06661aeaab2c"
--b2_e92d6eed5e3b708416fb06661aeaab2c
Content-Type: text/plain; charset = "UTF-8"
Content-Transfer-Encoding: 8bit
Testing
--b2_e92d6eed5e3b708416fb06661aeaab2c
Content-Type: text/html; charset = "UTF-8"
Content-Transfer-Encoding: 8bit
<body><h1>Hello, this is a test</h1></body>
--b2_e92d6eed5e3b708416fb06661aeaab2c--
--b1_e92d6eed5e3b708416fb06661aeaab2c
Content-Type: application/octet-stream; name="attachment.docx"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="attachment.docx"
UEsDBBQABgAIAAAAIQDfpNJsWgEAACAFAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAAC
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0
lMtuwjAQRfeV+g+Rt1Vi6KKqKgKLPpYtUukHGHsCVv2Sx7z+vhMCUVUBkQ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我使用的是旧版本的PHPMailer:
/**
* Assembles the message body. Returns an empty string on failure.
* @access public
* @return string The assembled message body
*/
public function CreateBody() {
$body = '';
if ($this->sign_key_file) {
$body .= $this->GetMailMIME();
}
$this->SetWordWrap();
switch($this->message_type) {
case 'alt':
$body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
$body .= $this->EncodeString($this->AltBody, $this->Encoding);
$body .= $this->LE.$this->LE;
$body .= $this->GetBoundary($this->boundary[1], '', 'text/html', '');
$body .= $this->EncodeString($this->Body, $this->Encoding);
$body .= $this->LE.$this->LE;
$body .= $this->EndBoundary($this->boundary[1]);
break;
case 'plain':
$body .= $this->EncodeString($this->Body, $this->Encoding);
break;
case 'attachments':
$body .= $this->GetBoundary($this->boundary[1], '', '', '');
$body .= $this->EncodeString($this->Body, $this->Encoding);
$body .= $this->LE;
$body .= $this->AttachAll();
break;
case 'alt_attachments':
$body .= sprintf("--%s%s", $this->boundary[1], $this->LE);
$body .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
$body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body
$body .= $this->EncodeString($this->AltBody, $this->Encoding);
$body .= $this->LE.$this->LE;
$body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body
$body .= $this->EncodeString($this->Body, $this->Encoding);
$body .= $this->LE.$this->LE;
$body .= $this->EndBoundary($this->boundary[2]);
$body .= $this->AttachAll();
break;
}
if ($this->IsError()) {
$body = '';
} elseif ($this->sign_key_file) {
try {
$file = tempnam('', 'mail');
file_put_contents($file, $body); //TODO check this worked
$signed = tempnam("", "signed");
if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), NULL)) {
@unlink($file);
@unlink($signed);
$body = file_get_contents($signed);
} else {
@unlink($file);
@unlink($signed);
throw new phpmailerException($this->Lang("signing").openssl_error_string());
}
} catch (phpmailerException $e) {
$body = '';
if ($this->exceptions) {
throw $e;
}
}
}
return $body;
}
/**
* Assembles message header.
* @access public
* @return string The assembled header
*/
public function CreateHeader() {
$result = '';
// Set the boundaries
$uniq_id = md5(uniqid(time()));
$this->boundary[1] = 'b1_' . $uniq_id;
$this->boundary[2] = 'b2_' . $uniq_id;
if($this->Timezone=='' || $this->Timezone==0) $this->Timezone = date_default_timezone_get();
date_default_timezone_set($this->Timezone);
$result .= $this->HeaderLine('Date', self::RFCDate($this->Timezone));
if($this->Sender == '') {
$result .= $this->HeaderLine('Return-Path', trim($this->From));
} else {
$result .= $this->HeaderLine('Return-Path', trim($this->Sender));
}
// To be created automatically by mail()
if($this->Mailer != 'mail') {
if ($this->SingleTo === true) {
foreach($this->to as $t) {
$this->SingleToArray[] = $this->AddrFormat($t);
}
} else {
if(count($this->to) > 0) {
$result .= $this->AddrAppend('To', $this->to);
} elseif (count($this->cc) == 0) {
$result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
}
}
}
$from = array();
$from[0][0] = trim($this->From);
$from[0][1] = $this->FromName;
$result .= $this->AddrAppend('From', $from);
// sendmail and mail() extract Cc from the header before sending
if(count($this->cc) > 0) {
$result .= $this->AddrAppend('Cc', $this->cc);
}
// sendmail and mail() extract Bcc from the header before sending
if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
$result .= $this->AddrAppend('Bcc', $this->bcc);
}
if(count($this->ReplyTo) > 0) {
$result .= $this->AddrAppend('Reply-to', $this->ReplyTo);
}
// mail() sets the subject itself
if($this->Mailer != 'mail') {
$result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
}
if($this->MessageID != '') {
$result .= $this->HeaderLine('Message-ID',$this->MessageID);
} else {
$result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
}
$result .= $this->HeaderLine('X-Priority', $this->Priority);
$result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (phpmailer.sourceforge.net)');
if($this->ConfirmReadingTo != '') {
$result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
}
// Add custom headers
for($index = 0; $index < count($this->CustomHeader); $index++) {
$result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
}
if (!$this->sign_key_file) {
$result .= $this->HeaderLine('MIME-Version', '1.0');
$result .= $this->GetMailMIME();
}
return $result;
}
以上两个函数正是Send()调用正文/标题的方式。
有人有任何想法吗?在这上面找不到任何东西。
答案 0 :(得分:0)
One of the PHPMailer examples shows IMAP upload,虽然我没有尝试附件。我怀疑问题在于您如何创建要上传的邮件;我不知道你从哪里得到这个:
$mail->CreateHeader() . $mail->CreateBody()
这将无法正常工作,因为标题和正文之间没有分隔符,可能导致无法使用的消息。 PHPMailer有一个内置函数来为您获取整个消息:getSentMIMEMessage()
,所以要上传消息的副本,您应该这样做:
$result = imap_append($imapStream, $path, $mail->getSentMIMEMessage());
并将示例的其余部分与您的代码进行比较。