使用imap_append时需要添加in_reply_to

时间:2016-05-28 09:35:56

标签: php imap

我在发送邮箱后试图附加我的邮件......

sbt
Messahe成功追加,但在检查

public function append_mail($mail_box, $replyto, $from, $to, $subject, $text, $attaches = []){
        $mailBox = "{".$this->imap_host.":".$this->imap_port.$this->imap_path."}".$mail_box;
        $dmy = date("d-M-Y H:i:s");
        $boundary = "------=".md5(uniqid(rand()));
        $msgid = $this->generateMessageID();
        $msg = "From: $from\r\n";
        $msg .= "To: $to\r\n";
        $msg .= "Date: $dmy\r\n";
        $msg .= "message_id: $msgid\r\n";
        $msg .= "in_reply_to: $replyto\r\n";
        $msg .= "Subject: $subject\r\n";
        $msg .= "MIME-Version: 1.0\r\n";
        $msg .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n";
        $msg .= "\r\n\r\n";
        $msg .= "--$boundary\r\n";
        $msg .= "Content-Type: text/html;\r\n\tcharset=\"ISO-8859-1\"\r\n";
        $msg .= "Content-Transfer-Encoding: 8bit \r\n";
        $msg .= "\r\n\r\n";
        $msg .= "$text\r\n";
        if(!empty($attaches)) {
            $msg .= "\r\n\r\n";
            $msg .= "--$boundary\r\n";
            foreach ($attaches as $filename => $filelink) {
                $attachment = chunk_split(base64_encode(file_get_contents($filelink)));
                $msg .= "Content-Transfer-Encoding: base64\r\n";
                $msg .= "Content-Disposition: attachment; filename=\"$filename\"\r\n";
                $msg .= "\r\n" . $attachment . "\r\n\r\n";
            }
        }
        $msg .= "\r\n\r\n\r\n";
        $msg .= "--$boundary--\r\n\r\n";
        imap_append($this->get_imap_stream(),$mailBox,$msg,"\\Seen");
    }

protected function generateMessageID() {
        return sprintf(
            "<%s.%s@%s>",
            base_convert(microtime(), 10, 36),
            base_convert(bin2hex(openssl_random_pseudo_bytes(8)), 16, 36),
            $_SERVER['SERVER_NAME']
        );
    }

它没有返回message_id和in_reply_to ...

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我使用此参数

解决了这个问题
$msg .= "Message-Id: $msgid\r\n";
$msg .= "In-Reply-To: $replyto\r\n";