Application Emails with Amazon Simple Email Service

Published | 5 min read

Most web applications at some point need a way to send emails. Whether it is just a welcome email, password reset email or emails for exceptions. There are a number of email providers out there you can use to send transactional emails.

When I set up GrowRecruit I originally used SendGrid. SendGrid costs $9.95 a month for up to 40,000 emails. However, they recently sent me an email saying as of 1st January the price is going up to $14.95 per month.

Given I am only using this for sending password reset emails and exceptions I send less than 20 emails a month.

I had been planning on switching over to Amazon Simple Email Service (SES) for a little while now and this was just the push I needed.

What is Amazon’s Simple Email Service?

Amazon SES is a cloud-based email sending service for digital marketers and developers for sending marketing, notification and transactional emails. For low volumes of emails, it is incredibly cheap if not free to use.

What does Amazon SES Cost?

There are no monthly fees for Amazon SES and the cost can even be free if you are hosting your application using Amazon EC2.

For EC2 hosted applications you get 62,000 emails a month free, and the cost is just $0.10 for every 1,000 emails after that. If you send attachments with your email it will cost an additional $0.12 for each GB you send.

For non-EC2 hosted applications it costs just $0.10 for every 1,000 emails you send along with the same charges for attachments.

I am not using this for receiving email but if you do you get the first 1,000 emails a month free.

How to Set Up Amazon SES

You will obviously need an AWS account to get started. I am not going to go into the details here. Once you log in you will need to search for Simple Email Service in the search bar.

Amazon Simple Email Service

Verify your domain

To get started you need to add the domain you plan on sending email from. Click Domains under Identity Management from the menu and click Verify New Domain.

Verify New Domain

Enter your domain and tick the Generate DKIM Settings checkbox. DKIM signatures are a way for email servers to verify that the email comes from your domain and avoid it being marked as spam.

On the next screen, it will list all the DKIM and TXT verification settings you need to apply. If you are using Route 53 for your domain DNS there is a button at the bottom you can click to set all this up for you. Leave the MX records unchecked unless you plan on receiving mail with SES too.

Add the sender email addresses

Once Amazon has validated your domain you need to validate all the email address you plan on sending email from. You will need to have your MX records set up correctly as Amazon will send you a link you need to click on to validate the address.

If you want to use a different email address in future you will need to go through this process again/

Get out of Sandbox

By default, Amazon puts you in Sandbox mode when you first signup for an account. If you try and send an email while in sandbox you will likely get the following error from your application:

Message rejected: Email address is not verified. The following identities failed the check-in region REGION: RECIPIENT-EMAIL-ADDRESS

This is because while in Sandbox you have to also verify all the recipient email addresses too. So basically you can only send emails to yourself, not overly useful.

If you go to the Sending Statistics page you will likely see something like this: Amazon SES Sandbox Mode

As the message suggests you need to send a request to support to get your sending limit increased. Amazon has a support page which outlines what you need to include in your support request.

It took about 24 hours but Amazon did approve my account and set my sending limit to 50,000 emails a day. It is going to be a long time before I go over that!

Ways to connect

Once you are out of Sandbox there are 2 main ways to use SES, the API and SMTP.

If you are coming from another email provider then you are likely using SMTP to send emails. You need to create some credentials for your application to use SMTP.

To set up credentials go to Email Sending > SMTP Settings and click the Create My SMTP Credentials button.


Once created you will get a username and password you can use to send emails. Plug that into your application and you are good to go.

Sending Emails in a .NET Core Application

I am sure there are a million different ways to send emails in .Net Core. I have found one of the simplest is to use MailKit and MimeKit.

With these imported you can send an email like this:

var message = new MimeMessage();
message.From.Add(new MailboxAddress("The Name of the Sender", _settings.SenderEmailAddress));
message.To.Add(new MailboxAddress(to));
message.Subject = subject;
message.Body = new TextPart(TextFormat.Text)
    Text = body

using(var client = new SmtpClient())
    client.Connect(_settings.SmtpServer, _settings.Port, _settings.Port == 465);
    await client.AuthenticateAsync(_settings.Username, _settings.Password);
    await client.SendAsync(message);
    await client.DisconnectAsync(true);

In the above example, I have the email server settings stored in appsettings.json. These then just get overridden by Docker environment variables in production.

If you need a mail server for development you can either run one locally or use something like MailTrap.

Was this post useful?
If you found this post useful and would like to support me, you can do so by buying me a coffee. Donations help keep this blog ad free.


Taking a Creative Sabbatical as a Software Engineer

Taking a Creative Sabbatical as a Software Engineer

  • 28 September 2022
The last couple of years have been tough for many people. A mix of lockdowns and general anxiety has left many feeling burnt out and exhausted. For software developers, the move to working 100% remotely wasn’t as much of an upheaval as it has been fo...
Adding Inline Javascript to a React App

Adding Inline Javascript to a React App

  • 11 February 2022
Let me start this with a disclaimer, I am not a React expert and I am sure there are probably other ways to do this. If you know of a better way then please let me know in the comments! I have recently added Giscus to my blog which is a great way to ...
Privacy Focused Blog Services

Privacy Focused Blog Services

  • 28 January 2022
Towards the end of 2021, I started getting into web3 a lot more. Not only did I join the Developer DAO but I also launched my own NFT collection and wrote a few blog posts on the topic. One of the key components of web3 is the ownership of data. In w...
What is DeFi? Understanding Decentralized Finance

What is DeFi? Understanding Decentralized Finance

  • 19 November 2021
If you are new to the crypto space the concepts of decentralised finance can seem a bit overwhelming. There are so many new terms to try and understand, it can be challenging to see how everything fits together. I have been working in the traditional...
Using Hashnode as a Source for Gatsby

Using Hashnode as a Source for Gatsby

  • 05 November 2021
I have done quite a few website migrations over the years. My blog like many first started out on WordPress. After several attempts at optimisation, I ended up generating a static version of my WordPress website. On my static site generation journey...
What is Web3? The Decentralised Internet Explained

What is Web3? The Decentralised Internet Explained

  • 15 October 2021
If you have stumbled upon this article you have probably seen the term web3 being mentioned around the internet. Especially on Twitter at the moment it seems to be the latest buzzword. With all the hype around NFTs and crypto at the moment, a lot of ...
Ditch the Ads: The Future of Website Monetization

Ditch the Ads: The Future of Website Monetization

  • 08 October 2021
Do you remember that scene in Ready Player One, when IOI are showing what the future of the Oasis will look like once they take over? “We have determined that we’ll be able to fill 80% of the user’s display with advertising before inducing seizures”...
Dealing with Imposter Syndrome as a Software Developer

Dealing with Imposter Syndrome as a Software Developer

  • 28 May 2021
I have been a professional software developer for over a decade and I have been writing code for over 25 years. However, sometimes I still feel like a fraud. It turns out, I am not the only one that feels this way and they have a name for it, it is c...