I'm trying to send the following raw email message generated by PHPMailer 5.2.9 using the SES SDK 2.7 sendRawEmail
method:
Date: Tue, 28 Oct 2014 03:34:18 +0000
From: someemail@gmail.com
Reply-To: someemail@gmail.com
Message-ID: <c738074625a476ed8e2793323ad0b3b2@*.dev>
X-Priority: 3
X-Mailer: PHPMailer
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="b1_c738074625a476ed8e2793323ad0b3b2"
Content-Transfer-Encoding: 8bit
To: someperson@gmail.com
Subject: Test subject (TID #1, SID #2)
--b1_c738074625a476ed8e2793323ad0b3b2
Content-Type: text/plain; charset=us-ascii
Test email for _Some One_!
--b1_c738074625a476ed8e2793323ad0b3b2
Content-Type: text/html; charset=us-ascii
Test email for <i>Some One</i>!
--b1_c738074625a476ed8e2793323ad0b3b2--
Here is the code used to generate the raw email and then send it:
$mail = new PHPMailer();
$mail->addAddress($to);
$mail->setFrom($from);
$mail->Subject = $subject;
$mail->CharSet = $char_set;
$mail->AltBody = $text;
$mail->Body = $html;
$mail->isHTML(true);
$mail->addAttachment($attachment);
$mail->preSend();
$args = [
'Source' => $from,
'Destinations' => [$to],
'RawMessage' => [
'Data' => $mail->getSentMIMEMessage()
]
];
$aws = Aws\Common\Aws::factory(app_path() . '/config/aws.php');
$ses = $aws->get('ses');
$send_result = $ses->sendRawEmail($args);
I get no errors in the $send_result
, just a standard 'MessageId' and 'RequestId' as I would with a successful send (and it does actually send).
I've tried with and without attachments as well, but it still sends the message as a garbled mess. This is what is received: http://prntscr.com/50ij42
What am I doing wrong here?