开发者

How to get the message body from PHPMailer?

开发者 https://www.devze.com 2023-03-30 04:46 出处:网络
I use PHPMailer to send email via SMTP. It works, but it doesn\'t save the sent emails in sent items. I want to make to sent emails in the sent items, any idea?

I use PHPMailer to send email via SMTP. It works, but it doesn't save the sent emails in

sent items. I want to make to sent emails in the sent items, any idea?

I know can use imap_append func开发者_如何学运维tion to achieve it. But, how to do that?

The PHPMailer seems doesn't has the function to return the $message.

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);

};

How to get the message body from PHPMailer?


The instance variables from PHPMailer are all public. Looking at the source you can just use:

$mail->Body

If you want the plain body including the all boundaries you could also use:

$mail->CreateBody();

See: http://phpmailer.svn.sourceforge.net/viewvc/phpmailer/trunk/phpmailer/class.phpmailer.php?revision=452&view=markup


The PHPMailer seems doesn't has the function to return the $message.

Yes, it does. At least in version 5.2.28 there is a method getSentMIMEMessage() to get the full MIME message (different from the email body). That method only works after sending the email, or calling the preSend() method.

0

精彩评论

暂无评论...
验证码 换一张
取 消