creating .eml file

barry cox
  • barry cox

    barry cox - 2013-07-13

    i'm using PHPMailer to send emails to my guests. i've been hand coding the headers etc and it finally got old so PHPMailer does it in a snap!

    however now i would like to save a copy of the email i send as an .eml file for archiving.

    trying to figure out how to get exactly the file that PHPMailer sends (without sending it and then retrieving it from IMAP which seems wasteful).

    tried the callback action function and have it partially working, but saving just the $body doesn't work. needs something else (headers, MIME, etc) trying to add on the beginning but unable to make it work.

    has anyone solved this problem? is there a way to pull the whole email string?

    Last edit: barry cox 2013-07-13
  • Marcus Bointon

    Marcus Bointon - 2013-07-13

    Firstly, the project is now on GitHub:

    You can get the complete message by getting it ready to send as usual, but then call $mail->PreSend(), then you can get the message by calling $mail->GetSentMIMEMessage(). This doesn't require that you actually send anything.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks