Note: if you want to setup SES in a way that scales much better and functions even with non-PHP sites, please read this more recent HowTo: How to configure your Postfix server to relay email through Amazon Simple Email Service (SES)
Here’s how you can start using Amazon’s new SES (Simple Email Service) without having to actually implement it in the php of your website:
- Extract the files and create a new one named “aws-credentials” with your key data in it; for example:
AWSAccessKeyId=022QF06E7MXBSH9DHM02
AWSSecretKey=kWcrlUX5JEDGM/LtmEENI/aVmYvHNif5zB+d9+ct
- Verify an email address to use with SES
./ses-verify-email-address.pl -k ./aws-credentials -v someaddress@yourdomain.com
- Check the email account for the address you’re verifying and click on the provided link.
- Send a test email:
echo "This is only a test." | ./ses-send-email.pl -k ./aws-credentials -s "test subject for email" -f someaddress@yourdomain.com someaddress@yourdomain.com(Note – Until you receive production access to Amazon SES, you can only send to addresses you have verified. You can request production access here.)
- Edit the sendmail_path config in your php.ini as follows:
sendmail_path = /path/to/ses-send-email.pl -k /path/to/aws-credentials -f someaddress@yourdomain.com -r
- Restart/reload Apache and that’s it!
(Additional notes – The “From” address you set in your php.ini file will override any mail headers you set in php. Sending will fail if you try to set the “From” header to an unverified address or when setting the “Reply-To” header at all in php.)
[...] This post was mentioned on Twitter by Michael Jensen, Millcreek Systems. Millcreek Systems said: Switch your PHP site to use Amazon SES in a few simple steps: http://urlpie.com/eL3GC6 [...]
It’s taking a long time to get approved for “production access” Much longer than I expected.
I can’t seem to get this solution to work. Did anyone else experience problems with this method?
Where did you run into problems?
Tried this solution but does not work. I installe all the SES scripts unser /usr/sbin/SES and pointed the sendmail route in php.ini to that directory where the .pl file and aws-credentials are. Running the .pl file from the console sends the mail fine, but when I run @mail() from myPHP program it just won’t send the mail.
Please advise and thanks in advance.
Jerry
Verify that your php setting is correct by checking the output of ini_get(‘sendmail_path’) Also verify that the script can be run as the user that apache runs as (www-data on debian/ubuntu)
Thanks Mill,
Great tip.
You also need to soft link the file SES.pm to your perl path /etc/perl (in my Ubuntu box) as well. Otherwise you might encounter the error
“Can’t locate SES.pm in @INC”
Somehow the mail is not going from php mail function. I am on ubuntu 11.04. Sendmail path is correct. The perl script has run permission for www-data users. And mail function is getting called. (Confirmed by enabling mail logging).
I have production account. What could be the reason?
I’m not sure what would be causing that without having access to the system in question. You could try switching to the www-data user and running your sendmail_path command from the command line to see if it outputs any helpful error messages.
sendmail_path = perl -I/path/to/ses/folder /path/to/ses-send-email.pl -k /path/to/aws-credentials -f someaddress@yourdomain.com -r
Thanks a lot for your help and wonderful article.
[...] configure your server to send email through it regardless of what platform your site is built in (my previous post was only relevant to PHP servers) There are 3 main things you need to do to configure your Postfix server to relay email through [...]
This was extremely useful, thanks! Just had to make sure perl Digest/SHA.pm was installed.
Thanks Andrew! If you need a solution that scales better, checkout this howto for using postfix to relay e-mail through SES’s SMTP interface. http://www.millcreeksys.com/how-to-configure-your-postfix-server-to-relay-email-through-amazon-simple-email-service-ses/
Thanks Michael, This solution worked well and was easy to follow. The SES script include path worked on one server with a simple edit to the $PATH, I had to add some symlinks for it to work on another server. That stuff was easy enough to figure out. All in all only a few hours of installation and testing to get it up.
I only wish amazon made it more clear what all the approval steps were. We waited till the last minute wo do the final production approval step and it delayed us a bit.
I’m going to look at your newer SES posts and see about getting one of the larger scale solutions in place.