I am trying to send an email that contains an attachment (a pdf file) using the amazon SES API.
I am using Symfony2 so I included the AmazonWebServiceBundle in my project.
I can send a simple email (that has no attachment) pretty easily with the following code:
$ses = $this->container->get('aws_ses');
$recip = array("ToAddresses"=>array("Quilly@yourownpoet.com"));
$message = array("Subject.Data"=>"My Subject","Body.Text.Data"=>"My Mail body");
$result = $ses->send_email("Quilly@yourownpoet.com",$recip, $message);
Unfortunately, to send an email with attachment, i need to use the sendRawEmail function instead of the send_email function.
I am unable to find how to use this function, could anybody help?
After many tries, I got to the conclusion that sending emails to Amazon SES directly from the code is too much pain.
So I didn’t change a thing in the code and configured my postfix server instead.
I followed this procedure: http://docs.amazonwebservices.com/ses/latest/DeveloperGuide/SMTP.MTAs.Postfix.html and configured integration using STARTTLS.
I had to ask for SMTP credentials in the Amazon console.
Now it’s working fine, emails are sent properly through Amazon SES.