Ends in
00
days
00
hrs
00
mins
00
secs
ENROLL NOW

Get any AWS Specialty Mock Test for FREE when you Buy 2 AWS Pro-Level Practice Tests – as LOW as $10.49 USD each ONLY!

Email Sender Application with Amazon SES

Home » Others » Email Sender Application with Amazon SES

Email Sender Application with Amazon SES

Whether you’re part of a business or organization, sending out emails is crucial for connecting with people. More often than not, you’ll find yourself needing to send similar emails to a group and sometimes, they need to be dynamic. Yes, you can send out one email and just add everyone to the BCC but having a dynamic and more personalized email helps create a better connection between you and the recipient. This is a tutorial on how you can create your very own Batch Email Sender Application with just AWS and Python.

 

Prerequisites

In order to follow this tutorial, you must have the following installed and configured.

  • AWS CLI
  • Python (preferably 3.12)
  • Tutorials dojo strip
  • Boto3 Python Module
  • Text editor of your choice (preferably VS Code)

 

Amazon SES Identities

In Amazon SES, you can verify identities which will allow you to send emails using these identities. Currently, you can verify a Domain or an Email Address identity. For the purposes of this tutorial, we’ll only be using an Email Address identity.

 

Note: You can only send an email to verified email identities in sandbox mode.

 

To verify an Email Address identity, go to your Amazon SES Dashboard through the AWS Console.

Amazon SES

Go to “Identities” from the sidebar navigation and then click the “Create Identity” button.

Amazon SES Identities Dashboard

For the Identity type, choose “Email address” and input your email address. Click “Create identity” to save your settings.

Amazon SES Create Identity Dashboard

You will receive an email to confirm that this email address does belong to you.

 

Application Development

Now that you have a verified email identity, we can start the development of our application using Python and Boto3. There are 2 things that we need to set up in order to send dynamic emails. The first one is an email template.

 

Amazon SES Email Templates

An email template allows us to send dynamic emails with a few minor details that vary. Setting one up is pretty simple because all we have to do is refer to Boto3’s SES Documentation.

  1. Create a Python file called `main.py` and paste in the following code.

    1. Run the code with `python main.py`

     

    You can read Boto3’s SES Documentation for more details but here’s a gist of the code above. TemplateName is going to be the name of your template. There are no restrictions when it comes to naming your template but it does have to be unique. The SubjectPart is self-explanatory. The TextPart and HtmlPart are the body of the email. TextPart only shows up when the recipient’s email engine doesn’t allow for HTML rendering.

     

    As you can see from the code above, there is {{name}}. This is a template variable and this is how we make dynamic emails. You can modify the value of this variable every time you send an email.

    Sending an Email

    Now that we have a registered email identity and a template to use, we can start sending out dynamic emails.

    1. Create a new Python file named “send_email.py” and paste the following code.

    1. Run the file using `python send_email.py`.

     

    Again, you can read up on Boto3’s SES Documentation for more details. The Source parameter will be the email identity you’ll be using to send the templated email. The Destination parameter may have multiple options such as the ToAddresses, CcAddresses, and BccAddresses. All these are lists of email addresses, making it easy for you to send to multiple people. The TemplateData is a dictionary where we take the variables in our template and give them a value. You must make sure that all variables in the template has a value provided for in the TemplateData because failing to do so will lead to your email not sending.

     

    Note: I suggest that you add your email as a BccAddresses to check if emails are being sent.

Get any AWS Specialty Mock Test for FREE when you Buy 2 AWS Pro-Level Practice Tests – as LOW as $10.49 USD each ONLY!

Tutorials Dojo portal

Learn AWS with our PlayCloud Hands-On Labs

Tutorials Dojo Exam Study Guide eBooks

tutorials dojo study guide eBook

FREE AWS Exam Readiness Digital Courses

Subscribe to our YouTube Channel

Tutorials Dojo YouTube Channel

FREE AWS, Azure, GCP Practice Test Samplers

Follow Us On Linkedin

Recent Posts

Written by: Mark Flores

Mark Achiles is the co-founder of AWS Cloud Club - PUP Manila, the first and pioneering AWS Cloud Club in the Philippines leading the movement of bridging the gap between theory and practice for students. He is an undergraduate in the Polytechnic University of the Philippines taking a Bachelor's Degree in Computer Science, an AWS Certified Cloud Practitioner, and an intern for Tutorials Dojo.

AWS, Azure, and GCP Certifications are consistently among the top-paying IT certifications in the world, considering that most companies have now shifted to the cloud. Earn over $150,000 per year with an AWS, Azure, or GCP certification!

Follow us on LinkedIn, YouTube, Facebook, or join our Slack study group. More importantly, answer as many practice exams as you can to help increase your chances of passing your certification exams on your first try!

View Our AWS, Azure, and GCP Exam Reviewers Check out our FREE courses

Our Community

~98%
passing rate
Around 95-98% of our students pass the AWS Certification exams after training with our courses.
200k+
students
Over 200k enrollees choose Tutorials Dojo in preparing for their AWS Certification exams.
~4.8
ratings
Our courses are highly rated by our enrollees from all over the world.

What our students say about us?