Reputation: 330
I'm trying to use Amazon SES for sending mail(with or without attachments) using AWS-SDK and sendRawEmail()
.
But it always bounces back with the error "From" is missing in header.
The code is as followed:
$header .= "From: [email protected] \r\n ";
$header .= "To: [email protected] \r\n ";
$header .= "Reply-To: [email protected] \r\n ";
$header .= "Subject: Testing Attachments \r\n ";
$header .= "MIME-Version: 1.0 \r\n ";
$header .= "Content-Type: text/plain; charset=utf-8 \r\n ";
$header .= "Content-Transfer-Encoding: 7bit \r\n \r\n ";
$header .= "This is normal content \r\n ";
$result = $client->sendRawEmail(
array('RawMessage' => array('Data' => base64_encode($header)), 'Source' => '[email protected]', 'Destinations' => array('[email protected]'), 'SourceArn' => 'arn:aws:ses:eu-west-1:1234:identity/[email protected]', 'FromArn' => 'arn:aws:ses:eu-west-1:1234:identity/[email protected]')
);
If I don't give "Source", "Destinations" in sendRawEmail()
then it gives error "From" header is missing and if those parameters are given that the mail bounces with the same error.
Thanks in advance for helping me out finding the solution for the same.
Upvotes: 0
Views: 1996
Reputation: 52443
I had this same issue when using another language SDK.
base64_encode($header)
Don't encode it. Remove base64_encode
Upvotes: 2