DEV Community

loading...
Cover image for How to send an email with AWS SES and track events with Configuration Sets?

How to send an email with AWS SES and track events with Configuration Sets?

juanc4milo profile image juanc4milo Originally published at juanc4milo.dev ・4 min read

Amazon Simple Email Service is a flexible and scalable email service that allows you to send mail from within any application.

Through this service, you can send emails and receive information on events that the recipient performs, such as mail delivered to the server, mail opening, or the recipient clicked on any link within the email.

To achieve that, you need to do the following steps:

Verify a Domain

The first thing you need to do is enter the domain that the email account belongs to so that Amazon can verify that the domain is yours. To do this, enter the Domains section and enter the domain:

image.png

Then, on the DNS settings you own (Godaddy, Hostgator, route53, etc.), you must create and enter the verification record sets that Amazon delivers.

image.png

image.png

Amazon must verify the domain, so you must enter this information in DNS settings.

If you are using Cloudfare or any CDN, you must enter this settings too.

Just wait 5 minutes to propagate the changes around the DNSs...

image.png

Verify Email address

Additionally, Amazon must verify a valid and existing email account. To do this, you must enter Amazon SES to the Email Address section, enter the email account and then go to the inbox of the specified mailbox and click on the link that allows you to verify the account.

image.png

Create a Configuration Set

To create a set of configurations in Amazon SES, go to the Configuration Sets section and click on the Create Configuration Set button.

image.png

Assign a name to the Configuration Set:

image.png

After assigning the name, it appears with no destinations created:

image.png

Enter into the configuration set:

image.png

You select the way you want to report the events:

image.png

For this example, I enabled Amazon SNS:

image.png

AWS SES reported these types of events when they occur. Select the one that suits you best.:

Send: A successful Amazon API call has been made to send mail and Amazon SES will attempt to deliver the mail.

Reject: Amazon SES accepted the email but determined that it contained malware and rejected it, thus, the email will not be sent.

Delivery: Amazon SES delivered the mail to the recipient's mail server.

Bounce: The recipient's mail server has rejected the mail, due to many causes, such as the inbox is full or the recipient does not exist.

Complaint: The email has been delivered to the recipient, but marks it as spam.

Click: The recipient clicked on one or more links included in the email.

Open: The recipient received the message and opened it in their email client.

Rendering Failure: The mail has not been sent due to a problem with the reading of the designated template for the mail.

Rendering Success: The email was sent using the templates configured in Amazon SES.

image.png

Select the SNS topic before configured to subscribe to notifications:

image.png

Save the configuration and a box will display the information entered:

image.png

Test

To send a test email, select the domain, and click on the Send a Test Email button:

image.png

Then, enter the following fields, where the RAW field indicated the mail format:

image.png

Include the following text in the body of the message. This text includes a tag that indicates the that AWS used to report the events:

X-SES-CONFIGURATION-SET: myConfigSetsName
X-SES-MESSAGE-TAGS: DimensionName=DefaultValue
From: emailfrom@domainexample.com
To: emailto@domainexample.com
Subject: Test email
Content-Type: multipart/alternative;
    boundary="----=_boundary"

------=_boundary
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

This is a test email with config sets.

<a href="https://aws.amazon.com/">Amazon Web Services</a>
------=_boundary
Enter fullscreen mode Exit fullscreen mode

Click on the send button and an email should reach the recipient's inbox:

image.png

One last thing...

To report an open email, Amazon SES includes a blank image at the end of the email so that when the user opens the email, it triggers an event that AWS captured.

For this reason, a restriction of the service is that the originating email account must be marked as a safe sender so when the recipient opens the email, it downloads all its content completely and could launch the event.

Other articles that you might like...

Do you like it? You can buy me a beer if you want.

Originally published at juanc4milo.dev

Discussion (3)

pic
Editor guide
Collapse
annaa_darden profile image
Annaa Darden

Hey guys! I was stuck in sending the professional mail to my client but after reading this post my problem has been solved. I also need a writing service to write best essay for my office essay writing competition and then my friend suggested me this website. This is really very impressive.

Collapse
juanc4milo profile image
juanc4milo Author

Good that your problem was solved! Thanks for your feedback.

Collapse
jasondayee profile image
Jason

It's clear !