amazon ses is a very robust service for sending and receiving email within the aws ecosystem (most people use it for sending outbound). if you’re a new aws customer, you can use it for free for one year under their free tier. configuring your site to use aws ses to send email to the outside world can sometimes be difficult though and that is why this post exists. any competent system administrator will already know that you should not simply setup a web server and expect it to be able to send email to the outside world without issues. that’s what email servers are for, obviously. this was a huge problem at a job despite them having an abundance of technical knowledge. we had sites in prod actually using localhost smtpd to send email to the company’s clients, then had people wondering why there was a problem with users not receiving email, or being flagged as spam. settings up wordpress to use ses is actually a lot easier than you think and you don’t even need to touch your dns spf record. as a matter of fact you don’t even need to think about reverse dns (rdns) or dkim. this is because you will be allowing the domain amazonses.com to send on behalf of your domain and amzonses.com has spf and dkim setup correctly. so you will be delegating the burden of managing the more technical aspect of email servers to amazon ses and using their massive infrastructure for practically nothing. most things that are too good to be true usually are, but not this time.
after signing up for an account at aws.amazon.com, you will need to open a support case to move your account out of the ses sandbox. once you’ve done that, navigate to ses and verify your domain which will require you to create a dns txt record called “_amazonses” without the quotes with a certain value you are provided by aws ses. once you’ve done that you should see a status of verified.
after your domain is verified, go to smtp settings on the left. note the server name, you will need this later. for the us-east region this will be
email-smtp.us-east-1.amazonaws.com. click on the create my smtp credentials button. you could change the name to make it reflect its purpose. an example is ses-smtp-user.contosocom. click create and download the credentials on the next page by clicking the button in the bottom right of the screen. you will need both values of
smtp username and
go to your wordpress admin dashboard and install the plug-in called wp mail smtp and go to the settings for email.fill in your from email and from name fields. make sure send all email through smtp is checked instead of the php mail() function. set the smtp host field to whatever server name was provided to you on the ses settings page of ses.
smtp port: 587 (if that doesn’t work try 25 or 465
use tls encryption. this is not the same as starttls. for most servers ssl is the recommended option.
check the box yes: use smtp authentication.
username: enter the username of the user you created under smtp settings in ses. it’s the weird-looking one with a long alphanumeric string of letters and numbers and not the clean one like ses-smtp-user.
password: this is the long string of random characters.
click on save changes and then send yourself a test email with the button below save. this will provide a verbose log to help you troubleshoot if any errors occur.
a couple of things to think about are:
- are any ports blocked outbound from your host?
- is a firewall enabled?
- could your isp be blocking port 25 outbound?
- are you underqualified to be messing around with these types of things?
- email headers are read bottom to top, not top to bottom
when you receive the test email you should notice that it is being sent via amazonses.com. this is hardly noticeable to end users but if you wanted both the from and mail from fields to be set to your domain, additional configuration will be required.
delivered-to: [email protected] received: by 10.31.157.76 with smtp id g73csp545051vke; sat, 3 sep 2016 18:04:03 -0700 (pdt) x-received: by 10.237.38.35 with smtp id z32mr32385280qtc.69.1472951043619; sat, 03 sep 2016 18:04:03 -0700 (pdt) return-path: <[email protected]zonses.com> received: from a8-39.smtp-out.amazonses.com (a8-39.smtp-out.amazonses.com. [126.96.36.199]) by mx.google.com with esmtps id 87si10830184qks.19.2016.09.03.18.04.03 for <[email protected]> (version=tls1 cipher=ecdhe-rsa-aes128-sha bits=128/128); sat, 03 sep 2016 18:04:03 -0700 (pdt) received-spf: pass (google.com: domain of [email protected]zonses.com designates 188.8.131.52 as permitted sender) client-ip=184.108.40.206; authentication-results: mx.google.com; dkim=pass [email protected]; spf=pass (google.com: domain of [email protected]zonses.com designates 220.127.116.11 as permitted sender) smtp.mailfr[email protected]amazonses.com dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=6gbrjpgwjskckoa6a5zn6fwqkn67xbtw; d=amazonses.com; t=1472951042; h=date:to:from:subject:message-id:mime-version:content-type:content-transfer-encoding:feedback-id; bh=8nh7jhmdxgvd6ryqsoj6uggippha7vgvczslnkvyoi4=; b=acm3j/3ml/qdk5k44qrwdv+apvjmzwcuxp9o8s8lrbzkbbzqhlg8di/qhn9m6kz1 i314teiwvxav1ykrkq8h35qbuwqtk7vblds4xtpmf+ct+u0zozwcf1aajlmmbkglitc oewjqsmo67ouw93lgaen8x63gz+wjolkexh+e/nq= date: sun, 4 sep 2016 01:04:02 +0000 to: [email protected] from: travis runyard <[email protected]> subject: wp mail smtp: test mail to [email protected] message-id: <[email protected]il.amazonses.com> x-mailer: phpmailer 5.2.14 (https://github.com/phpmailer/phpmailer) mime-version: 1.0 content-type: text/plain; charset=utf-8 content-transfer-encoding: 8bit x-ses-outgoing: 2016.09.04-18.104.22.168 feedback-id: 1.us-east-1.tvhugpzroehufyzcgnvondgagq81+as3rbp6j7dfkx4=:amazonses this is a test email generated by the wp mail smtp wordpress plugin.