我使用PHPMailer通过SMTP发送电子邮件。它工作,但它不保存发送的电子邮件在
sent items
。我想在sent items
中发送电子邮件,你知道吗?
我知道可以用imap_append
函数来实现。但是,怎么做呢?
PHPMailer似乎没有返回$消息的函数。
if ($return = $mail->Send()) {
$stream = imap_open("{{$host}:993/imap/ssl}Sent Items", $user_name, $user_pwd);
imap_append($stream, "{{$host}:993/imap/ssl}Sent Items" , $message , "''Seen");
imap_close($stream);
};
如何从PHPMailer获取消息体?
PHPMailer中的实例变量都是公共的。查看源代码,你可以使用:
$mail->Body
如果你想要包含所有边界的正文,你也可以使用:
$mail->CreateBody();
看:http://phpmailer.svn.sourceforge.net/viewvc/phpmailer/trunk/phpmailer/class.phpmailer.php?revision=452&视图=标记
PHPMailer似乎没有返回$消息的函数。
是的,它有。至少在5.2.28版本中,有一个方法getSentMIMEMessage()
来获取完整的MIME消息(不同于电子邮件正文)。该方法仅在发送电子邮件或调用preSend()
方法后有效。