Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the message body from PHPMailer?

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 function 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?

like image 273
Cynial Avatar asked Aug 23 '11 08:08

Cynial


People also ask

Is PHPMailer secure?

PHPMailer doesn't create/use any SQL itself, nor does it have anything to do with javascript, so it's secure on those fronts.

Is PHPMailer SMTP?

PHPMailer can use a non-local mail server (SMTP) if you have authentication. Further advantages include: It can print various kinds of error messages in more than 40 languages when it fails to send an email. It has integrated SMTP protocol support and authentication over SSL and TLS.


1 Answers

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

like image 51
Danny Hiemstra Avatar answered Sep 27 '22 21:09

Danny Hiemstra