There was some twittering yesterday about the possibility of Amazon’s Simple Email Service being added to Magento, so that outbound emails could enjoy the high level of deliverability that comes from ESP’s (Email service providers) like Mailchimp or Campaign Monitor.
Update July 2013: I have since released a premium extension for sending email using Amazon SES called MageSend, if you’re having toruble sending email with Magento, please check it out, it was created to solve many common Magento email issues.
I decided to investigate what it would take to add the functionality to my Magento Email extension, SMTP Pro, and the good news is, not too much. I’ll run through what’s changed in SMTP Pro and how the changes were made in this article. If you don’t actually care, just jump straight to the downloads to get the new version, or get it on Magento Connect.
We use Google Apps accounts as our store email accounts and I have no complaints about the service at all. Deliverability is excellent, reliability has never been an issue (how often is gmail down, after all?). However, it’s comforting to know that if something changed, we could now swap to Amazon’s equally reliable, scalable, pay-per-use option quickly and easily.
Implementing the changes
I was able to integrate Magento to SES in a very short amount of time thanks mostly to the work of Christopher Valles, he made a Zend transport for SES, which I was able to plug in to my extension quite simply. Christopher, if I’m ever back in Spain, I’ll buy you a beer.
Asides from the SES API, the extension just needed a few UI tweaks, and to better handle the slightly different paradigm that comes with a non-SMTP email transport (mostly in self testing).
So it hasn’t changed too drastically – ready to give it a go? Read on for set up instructions.
Setting up Simple Email Service
Getting the SES up and running is really easy. Here’s what you need to do.
1) Signup Signup for SES (and if you haven’t already, AWS)
2) Download Tools Get the SES command-line tools. They’re Perl scripts, so I’m going to assume you have a Perl environment installed to run them.
3) Verify Email Verify your test email address(s) using this command:
ses-verify-email-address.pl -v email@example.com
Note: You can set an environment variable to save having to specify the location of your AWS credentials all the time.
You should get an email like this, follow the link to verify:
4) Test it Run a quick test
ses-send-email.pl -k aws-credentials -s "This is a test" -f firstname.lastname@example.org email@example.com < msgbody.txt
Assuming that worked, you should have the SES side of things all set up. Well done!
Setting up the Extension
To use SES with my SMTP Pro extension first make sure you know your access key and secret key.
Input these into the section in System-Configuration-System-SES settings.
Make sure you choose
SES (experimental) as the extension option in the General Settings section too.
You’ll need to make sure the contact form email address is verified with SES (System-Configuration-Contacts), and also the contact form sender address (System-Configuration-Store Email Addresses). In my testing I just made all of these the same address for simplicity.
If you get this part wrong, it’ll break the email sending and self-test. It is important for SES during development as all emails sent to & received from need to be verified. Once you’re in SES production mode that won’t be required.
A symptom of getting it wrong is an error like this in
<ErrorResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/"> <Error> <Type>Sender</Type> <Code>MessageRejected</Code> <Message>Email address is not verified.</Message> </Error> <RequestId>0da2c23a-52a0-11e0-8fd7-f3adea62ee04</RequestId> </ErrorResponse>
Once you have it all set up you should be able to run a self test, if should give you output like this:
You should also receive the two test emails like these:
If you see these emails with the amazonses.com
mailed-by header, then everything worked, yah! – now post a comment to tell me it worked so I can release without the (experimental) clause!
Please let me know any feedback about the new service. Particularly if you would like to use it in production. Also, thinking I should rename the SMTP Pro extension to something more like Magento Email Pro now that it’s not just SMTP – anyone care to weigh in on that?