If you have a legitimate need to send lot of emails from your software or application and you are already Amazon AWS user, you should definitely check Amazon Simple Email Serivce (SES). The total setup took me less than 30 minutes before I was able to send email using their transport.
There is good documentation on Amazon SES that you want to read to decide if it’s the right email service to use for your scenario. I have yet to evaluate the turn around time for AWS SES in sending email. The reviews that I came across have been mixed.
Here is my logic for trying this service
- GoDaddy, where my domain is registered, provides email service but it’s seriously limiting. They only allow 250 emails per day and paying more still does not let you scale easily. GMail also has limitations. Being able to talk to customers in a scalable way is very important to Mofinto. SES offers that.
- Since Mofinto already uses AWS, it’s no brainer for me to try to use this.
Using SendMail or someother email server may come free but it is involved and would take up a lot of time. Even then configuring for secure email with protocols like DKIM, SSL or TSL etc. is going to involve more work.
- SES provides TSL, DKIM authentication out of the box. More on DKIM later.
- SES also lets you test out sending the email, deal with bounced email, complaints etc.
- SES comes with monitoring and other conveniences and is a “Pay As You Go” service.
Here are the steps to enable it:
- If you have AWS account, login. If you do not, sign up for one.
- In the AWS management console, select SES.
- Click on SMTP settings and then click on mySMTP credentials. Details are given in AWS documentation. You can use console or API to do this. It’s very important that you save the credentials locally on your machine somewhere in a safe place. You need this later and this is the only time you get to download and save it. You can also copy and past it into a text document. It’s a good idea to also save the IAM User name, that AWS console generates, somewhere safe.
- In the SES management console, click on “Email Addresses” under “Verify Senders”
- Click on Verify a New EMail Address
- Type in the email you want to use for sending.
- AWS SES will send email to this account with a link that you have to click to verify.
- Repeat the above two steps for each of the email accounts you want to send mail to while testing the service.
- Note that each of the emails is added as a line to the “Email Addresse” under “Verify Senders”. It also indicates status of the verification process for each of the emails. Once you click on the link in the respective emails, the status for that particular email will change to verified.
- When all the emails are verified, you are ready. SES will place you in a sandbox environment. The only thing you have left to do is to test it, make sure everything is working and when you are all satisfied, request for production access.
- Since you are in sandbox, you can’t send to any email addresses outside those you verified.
The very basic test involves being able to send mail using SES. This is done by sending test mail through management console itself. To do this, go to “Email Addresses” under “Verify Senders” and select the email you want to use as sender. This will enable “Send a Test EMail” button next to “Verify a New EMail Address” button. Click on this, fill the form and vefify that you received the email.
There are multiple ways to send email using SES. You can use the console, existing software packages, integrate with your email server, or your application might send mail programatically either using SMTP or using the AWS SES API. Here is a document that describes how to do it using Php and mysql.
In case you are using PhpMailer (an open source php helper that lets you send SMTP mail), here is what you need to do make it work.
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Port = 465;// SSL port
$mail->Host = “ssl://email-smtp.us-east-1.amazonaws.com”; // This may be different depending on your region.
/*You can use tsl: or ssl:. I spent several hours struggling with why the mail was not going through. Until I realized that Apache is refusing TSL protocol, because I haven’t enabled it. I was able to find it when I turned on $mail->SMTPDebug. However, the debug outputs were ‘php echo’ statements in PhpMailer. To enable debug output to showup, I buffered the output and redirected it to a string that could be logged.*/
$mail->Username = “user name part of credentials you saved before”; // SMTP username
$mail->Password = “password part of credentials”; // SMTP password
$mail->Sender = “sender@email.com”; // verfied sender’s email
$mail->From = “sender@email.com;
$mail->FromName = “Name of the sender”;
$mail->AddAddress(“to@email.com”,”receiver’s name”); // verified receiver’s email and name.
$mail->AddReplyTo(“sender@email.com”, “Webmaster or Sender’s name”);
$mail->WordWrap = 50; // set word wrap
$mail->IsHTML(true); // send as HTML
$mail->Subject = “subject”;
$mail->Body = “body of text”;
$mail->AltBody = “Alt body”;
$mail->SMTPDebug = true;
/*As mentioned earlier, Php_mailer calls echo for all debug information. If SMTPDebug is turned on, buffer the echos and then output them to the log file.
Also be sure to end bufferring in case exception happens or otherwise.*/
if($mail->SMTPDebug) ob_start();
if(!$mail->Send())
{
if($mail->SMTPDebug){$strE = ob_get_contents();ob_end_clean();}
/* RaiseException simply logs and throws exception. You can append $strE saved above if you want to log. PhpMailer error messages are not descriptive enough in most cases and it’s a good idea to log the debug info collected through $strE */
$this->RaiseException(“Error in sending mail=”.$mail->ErrorInfo);
}
ob_end_clean();
// Successfully sent mail.
Ensuring that you are good citizen and behave with etiquette:
When email is sent because of the nature of email, delivery can not be guaranteed. However, you want your email to be not viewed as spam or annoying. As such there are certain steps you need to take to ensure your email is not misconstrued as spam. This url gives guidelines on how you can prevent your email is not viewed by receiving parties, Internet providers and Amazon SES as SPAM.
All the documents in this url should be read thoroughly.
It’s also important to have a process for handling bounced emails, complaints, Out of Office, and “suppressionlist” notifications. You should take action to remove emails that are notified as no longer in service, wrong, or against which you received complaints from SES. If your bounce or complaint statistics goes up, SES may deny your request to send email.
Amazon SES provide sandbox email to verify the process you have set up to deal with them. It’s outlined here. Note you should only send mail to the listed addresses @simulator.amazonses.com. Sending to other addresses that are not in this list even @simulator.amazonses.com, may result in being marked as spammer.
To increase authenticity, it’s advisable you sign all your communication with DKIM (Domain Key Identified Mail). DKIM attaches a new domain name identifier to a message and uses cryptographic techniques to validate authorization for its presence. The identifier is independent of any other identifier in the message, such in the author’s From: field. Amazon does the DKIM signing for you. All you have to do is, enable your domain to be verified by Amazon so that it can authenticate and sign your email before it sends it out.
The process is really simple. Follow the instructions in this link.
If you are using GoDaddy as the registrar for the domain, you need to add the CNAME records in GoDaddy service.
I looked for how to do this and there is very little help on this. So I will give you instructions on how to do this.
- Login to your Go Daddy account.
- Domain Manager
- Select

- Click on Edit
- Under the CName record table, click on quick Add button

- Now copy each of the three CName records from DKIM CName records generated using EasyDKIM as described in SES Easy DKIM document
- Note the Name should go in “Host” field and Value should go in “Points to field”.
- While Amazon says it will take 72 hours to verify, the DKIM status is updated in a few minutes. You go to the “Email Address”, click on the search icon against the particular email for which you are setting up DKIM. Click on DKIM, it will show the status as “pending” and once verified, it will change to “verified”.
The last step in DKIM setup is to enable it. The link to do this is in the same place as above.
After it’s enabled, send a test mail again. If you can view the header on your email client, you should be able to see the header contain “dkim=pass (ok)”. This means you are all setup to send DKIM signed emails and it’s successfully verified by the ISP and email client.
After you complete whatever other tests you want to run, the last thing to do is to request for production access. Click the button that says “Production Access” that’s in SES console dashboard. A support request form shows up, fill the fields appropriately and submit. You wait for Amazon to get back to you and in a day or two you should hear from them.
While this is long blog and seems like there are a lot of steps involved, the whole process took a day or so but with quick series of steps and then wait for the verification process. The actual time I spent doing the work was only an hour or so. Most of this hour was also consumed by trying to debug the problem with PhpMailer.
Hope this is helpful. As always, love to hear comments. While you are at it, check out Mofinto. It’s totally free.
Everyone needs financial planning. Mofinto is a simple tool that puts you in charge of your financial future, educates you and helps you plan your finances. Visit Mofinto.