Ideally, if your organization needs to send transactional or promotional messages, you wouldn't want to use your regular mail servers. It doesn't matter if you plan to send 10 emails or 10,000 emails, you may want to consider having a separate email infrastructure to handle those types of emails.

There are many options by which you can accomplish this setup. You can design and build your own email infrastructure and manage all areas, including the platform and software.

Another option is to subscribe to a cloud-based email sending service and not have to set up an infrastructure and forget about maintenance. One of the most well-known email sending services is called the Amazon Simple Email Service (SES)

And in this article, you will learn how to use Amazon SES to send emails using the Amazon SES console and the SMTP interface. You will also learn the needed preparations before you can start sending emails using Amazon SES.

Prerequisites

There are some requirements that you must have to follow along with the examples and steps in this article.

  • You must have an AWS account. If you don't have this, you can sign up for a new AWS account. All the steps that will be performed in this article will work with the AWS Free Tier subscription.
  • If you plan to verify the identity of the whole domain, you need to have access to your DNS host. Verifying a domain requires adding new DNS records to confirm domain ownership.
  • If you plan to verify the identity of an email address, you need to have a valid mailbox using that email address. Email address ownership confirmation requires access to the confirmation email from Amazon SES.

*Note: A new Amazon SES account starts as "sandboxed." This means that you can only send and receive emails using the verified domain or email address as sender and recipient. For example, for verified email domains (e.g., contoso.com), you can only use email addresses with @contoso.com as both sender and recipient.

Eventually, you can request to move your Amazon SES out of the sandbox.*

  • (Optional) An existing mail server or application to integrate with Amazon SES.

Accessing the Amazon SES Console

Assuming that you have just created your AWS account and have logged in for the first time, your brain goes, "Where's that SES console?". Given a multitude of services available in AWS, it is easy to get overwhelmed and not find what you're looking for right away.

While logged in to the AWS Management Console, the easiest way to find the service that you need is by using the search box. Just type the words "simple email" into the search box and click on the result, as shown in the demonstration below.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/719614e9-7978-4a84-b337-3b88b08dc794/find-ses.gif
Accessing the Amazon SES Console

Verifying Sender Identity

Before using Amazon SES to send emails, you must verify that you have the authority to use the sender identity that you will use. This process also helps avoid fraud by making sure that only legitimate domains or addresses are allowed to use the service.

There are two ways to verify sender identities. One is by verifying an email domain, another is by verifying an email address. Which one to use depends on your business requirements.

Verifying Domains

If you intend to use any email address under your domain, then verifying a domain is a must. When a domain is verified in SES, you can use any address as a sender as long as the domain part is your verified domain.

For example, if your verified domain is contoso.com, the addresses [email protected] and [email protected] are eligible to use as sender addresses.

To verify an email domain, under the Identity Management section, click on Domains. Next, click on Verify a New Domain.

In the Verify a New Domain pop-up box, enter the name of the domain you wish to verify. Then, click on Verify This Domain.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/cb52d988-9503-4335-b5fd-647f09f47c03/verify-domain1.gif
Verify a new domain

As you can see from the demonstration above, after adding a new domain to verify, a TXT record is created. You need to copy the TXT record and create it in your DNS host.

In the example below, a new TXT record is added for the domain lzex.cf using the values provided by Amazon SES. Note that your DNS management interface may be different from the example you see below.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/ad8b71b5-0862-41c9-a4bf-6c0c06f7eb29/Untitled.png
Creating a TXT record for domain verification

Once you've created the TXT record in your DNS host, go back to the Verify a New Domain page in Amazon SES. Check if the domain has been verified. If not yet verified, click on the refresh button.

If the correct TXT record is found, the domain status will change to verified. Refer to the screenshot below showing the that domain has been verified and enabled.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/652dc410-eef3-4bea-ae00-77d73deda2e5/Untitled.png
New domain is verified

Verifying Email Addresses

To confirm the identity of individual email addresses and enable them as senders, follow these steps.

Under the Identity Management section and click on Email Addresses. Next, click on Verify a New Email Address. Type in the email address you wish to verify into the Email Address box and click on Verify This Email Address.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/22432d14-9dc0-4f91-abde-11b71233cbc6/verify-address1.gif
Verifying an email address

As you can see at the end of the demonstration above, the new email address verification status is set to pending verification. The next step is to access the mailbox and confirm the email address using the link in the confirmation email sent by SES.

The screenshot below shows the verification email that was sent by AWS. To continue the verification, click the link in the message.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/c58d175f-f5ca-4146-8f4f-6034bd7aeead/Untitled.png
Email address verification address message

The link should automatically open in your web browser. If the verification is successful, you should get a message that is similar to the one shown below.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/70059672-6e46-4d60-bcc5-dbd3eb654a09/Untitled.png
Email address verification is successful

Go back to the Amazon SES console. Click on the refresh button in the Email Addresses page to retrieve the status of the email address verification. The verification status is now changed to verified.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/2229f450-11f9-4529-b40c-d1b117173b5d/Untitled.png
Email address is verified

Sending an Email using the Console

Perhaps the easiest way to send an email using Amazon SES is doing it from the console. However, using the console requires you to manually input information to send one email at a time. This method of usage makes the Amazon SES console suitable only for sending test emails.

There are two email format options available when using this method. These two email options are formatted and raw.

To access the send email interface in the Amazon SES console, you can:

  • If you will send an email using any address from your verified domain, go to Domains.
  • If you will send an email using an individually verified email address, go to Email Addresses.

Sending a Formatted Email

Sending a formatted email is the simplest option when using the console to send an email. With this option selected, you only need to input your message body, and Amazon SES automatically converts your content into a generic email format.

To send a formatted email, go to Domains or Email Addresses depending on your preferred sender address. Then, select the domain or email address from the list and click on the Send a Test Email button.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/cb256d96-15e3-4d4c-9e49-363b5179b958/Untitled.png
Opening the Send Test Email interface

In the Send Test Email pop-up,  make sure to select Formatted as the Email Format. Then, enter the required details such as the From, To, and Subject. Lastly, enter your message in the Body and click on the Send Test Email button when you're done.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/824b2cbc-ca15-45c0-b212-c81fd4e8a2bb/Untitled.png
Sending a formatted email from the console

And if all goes well, the test email should be delivered to the destination mailbox. The screenshot below shows that the message was received.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/78514e3e-a686-4bc9-bcb2-5d58b1eff5e6/Untitled.png
Formatted email sent from the console

Sending a Raw Email

The option to send a raw email allows you to craft a more complex message formatting. This means that you can use HTML formatting so you can design your message using HTML code.

For example, the HTML code below can be used as the message body.

Subject: Amazon SES Raw Email Test
MIME-Version: 1.0
Content-Type: text/HTML

<!DOCTYPE html>
<html>
<head>
<style>
body {background-color: powderblue;}
h1   {color: blue;}
p    {color: red;}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>

To send the raw email, go back to the Send Test Email interface again in the Amazon SES console. This time, select Raw as the Email Format. Enter the From and To addresses. Then, copy the code above and paste it into the Message box and click on the Send Test Email button.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/0dda93a4-e397-4a18-831c-ac8fcf0decad/Untitled.png
Sending a raw email from the console

When the message is received, the email would be displayed with HTML formatting.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e699ae1c-25f3-4849-8610-bc241b16ff8a/Untitled.png
Raw email sent from the console

As you can see from the email screenshot above, the email is rendered as an HTML formatted message.

Sending an Email using the SMTP Interface

The Amazon SES SMTP endpoints listen to the ports 25, 587, and 2587 for STARTTLS. As well as to ports 465 and 2465 for TLS Wrapper (SMTPS)

Amazon SES customers can send messages manually or programmatically - which means you can integrate your automation and background email sending processes with Amazon SES.

Before you can use the Amazon SES SMTP endpoint, you must obtain two things. The SMTP credential and SMTP endpoint address.

Getting the SMTP Endpoint Interface Details

To find the appropriate SMTP endpoint information for your account, go to SMTP Settings in the Amazon SES console. You should be able to find the relevant SMTP interface information, such as the Server Name and Port.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/9e7557a4-d539-49f0-891c-4c6a49ddf353/Untitled.png
Getting the SMTP interface details

Creating an SMTP Credential

The SMTP credential is not the same as your AWS credential. To obtain the SMTP credentials, click on the Create My SMTP Credentials button. Next, you can either enter the name you want to assign to the credential or accept the default name and click Create.

In the demonstration below, a new SMTP credential with the name SMTP1 is created.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/7f7db65d-4ea1-4d1d-8da5-5f6bc4490f62/smtp-cred.gif
Creating an SMTP credential

Once the SMTP credential is created, make sure to copy and save the SMTP username and password.

Sending an Email Through Amazon SES SMTP using PowerShell

Now that you've created the SMTP credential and have the SMTP details, you can use them to send an email through Amazon SES.

In this example, the email will be sent using the Send-MailMessage PowerShell cmdlet. Use the code below.

Make sure to use your SMTP credentials in the $smtpUserName and $smtpPassword variables. Also, update the email parameters like the smtpServer, Port, From, and To.

# Define username and password
$smtpUserName = '****SMTP USER NAME HERE****'
$smtpPassword = ConvertTo-SecureString '****SMTP PASSWORD HERE****' -AsPlainText -Force

# Convert to SecureString
[pscredential]$credential = New-Object System.Management.Automation.PSCredential ($smtpUserName, $smtpPassword)

# Send Email - change the values if needed.
Send-MailMessage -Credential $credential `
-useSSL `
-smtpServer 'email-smtp.ap-southeast-2.amazonaws.com' `
-port 587 `
-from '[email protected]' `
-to '[email protected]' `
-subject `
'Email via Amazon SES SMTP Endpoint' `
-body 'Email via Amazon SES SMTP Endpoint'

Once you've modified the code above, copy the entire code and paste it in PowerShell to run it. Refer to the demonstration below that shows the message being sent using PowerShell and received by the destination address.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/489fd75c-3bb0-44de-b441-ed6fcec326aa/send-smtp-ps.gif
Sending an email using PowerShell through Amazon SES SMTP Endpoint

Integrating with Your Existing Email Server or Application

Aside from using Amazon SES SMTP endpoint for sending emails programmatically, you can also integrate it with your mail server or email sending application.

In the example below, a mail server (hMailServer) is configured to send outbound messages using the Amazon SES SMTP endpoint as its smart host.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/1915bc67-79a6-489c-a867-4a1420d0f52b/Untitled.png
Using Amazon SES SMTP as a smart host

After setting the SMTP relayer settings, as shown in the above screenshot, the mail server now routes all outbound messages through Amazon SES. In the example below, a test message was sent to an external recipient (gmail.com) and was received.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a632dc45-6b65-48d8-831b-f7898acaf4f5/Untitled.png
Email sent via Amazon SES as SMTP smart host

Conclusion

Amazon Simple Email Service is indeed a 'simple' email service to configure, use, and get used to. Using Amazon SES instead of building your own email infrastructure can really save you from hardware, maintenance, and management cost.

In this article, you've learned how to prepare your domain or email address for use with Amazon SES. You've learned how to send formatted and raw emails using the Amazon SES console.

You've also learned how to use the Amazon SES SMTP interface to send messages programmatically and as an SMTP outbound smart host for your existing email servers and applications.

There are other ways of sending emails through Amazon SES that you can learn, like, using the API and SDK. However, those are for advanced usage scenarios and would be best suited for development purposes.

Further Reading