pie*_*nik 14
我找到了更简单的方法.PHPmailer将电子邮件准备为字符串 - 您只需将其放入正确的IMAP文件夹即可.
我使用此代码扩展了phpmailer类(因为vars受到保护,我无法访问它们):
class PHPMailer_mine extends PHPMailer {
public function get_mail_string() {
return $this->MIMEHeader.$this->MIMEBody;
}}
Run Code Online (Sandbox Code Playgroud)
PHP代码:
$mail= new PHPMailer_mine();
//code to handle phpmailer
$result=$mail->Send();
if ($result) {
$mail_string=$mail->get_mail_string();
imap_append($ImapStream, $folder, $mail_string, "\\Seen");
}
Run Code Online (Sandbox Code Playgroud)
它运作良好.
Nab*_*bab 13
现在PHPMailer中有一个方法getSentMIMEMessage,它返回整个MIME字符串
$mail = new PHPMailer();
//code to handle phpmailer
$result = $mail->Send();
if ($result) {
$mail_string = $mail->getSentMIMEMessage();
imap_append($ImapStream, $folder, $mail_string, "\\Seen");
}
Run Code Online (Sandbox Code Playgroud)
嗯,这非常困难,但是可以做到。
看一下imap-append函数。
通过连接到 IMAP 流资源,您可以使用 imap-append() 将邮件附加到 IMAP 帐户的“已发送”文件夹中。
但是阅读评论会告诉您,完成起来有点乏味,但肯定不是不可能 - 您可能需要自己编写一些代码,因为 phpmailer 不支持开箱即用(并且很可能是实施起来太耗时,而不是自己做一些东西)。