Search code examples
gmailphpmailergoogle-api-php-client

get raw rfc822 message from phpmailer


I am trying to use google-api-php-client and gmail-api to allow my users to authenticate their gmail accounts and send emails through my website. I asked a more generic questions earlier and decided to seek help from the PHPMailer community with this question.

I have used PHPMailer to send emails. And I want to know if I can extract the raw rfc822 message from my PHPMailer object after setting it up prior to sending. I should be able to then do a base64_encode on that string and set the "raw" property for my Google_Service_Gmail_Message.


Solution

  • No problem: Set up everything as if you were going to send, but instead of calling send(), call preSend(), then fetch the complete message using getSentMIMEMessage().