How To Send An Email Using Amazon Simple Email Service (SES) Part-(3 of 3)

Nafis Faysal
Codephilics
Published in
5 min readSep 2, 2019

In this article, we will explore step-by-step Sending An Email Using AWS SDK. We will use Go AWS SDK. Don’t worry if you are not familiar with Go Programming Language. I will explain every single detail. Hope this will give you a solid idea on AWS SDK for SES APIs and you can implement on your preferred Programming Language.

Goals

By the end of this tutorial:

  • We will have a solid understanding of AWS SES.
  • We will be able to send an email using AWS Go SDK.

Prerequisites

To follow this tutorial, you will have to have the following:

Send Email using AWS SDK for Go

Amazon’s simple email service (Amazon SES) allows developers to programmatically send emails through Amazon’s servers from any email address that they have verified in their AWS account.

Setup

If you follow the first part of this AWS SES series you can skip Verify Email Address with Amazon SES.

If you don’t have an AWS account, go to this link create your account, you will get 12-month free trial all most of the AWS services. Awesome right. Visit aws.amazon.com/free for full offer terms

  1. Sign in to the AWS Management Console
AWS Management Console

and open the Amazon SES console at https://console.aws.amazon.com/ses/

Amazon SES Console

2. With your new AWS account, or you have not requested a sending limit, your account in the Amazon SES sandbox with limited feature. This means that you will not be able to send email to addresses that aren’t verified with AWS. So you will need to verify email addresses whatever email address you plan on using for this service.

Email Addresses
Verify a new email address

3. Enter the Email that you want to verify (make sure you own the Email) and select “Verify This Email Address”. Amazon will send you an email with a link to verify that email address with Amazon SES.

Verify a new email address
Verification email

4. In Amazon SES console, under Identity Management, choose “Email Addresses” to view the email address that you verified.

Verified email list

5. Install the AWS SDK

Install AWS SDK for Go

6. We need to create an AWS access key. Log in to your AWS account. In your amazon management console, click “My Account” in the top right corner and then select “Security Credentials”.

AWS management console

7. This will take you to the “Your Security Credentials” page where a modal will give you the two option to “Continue to Security Credentials” or “Get Started with IAM Users”. Select “Continue to Security Credentials”.

Continue to security credentials

8. Select “Create New Access Key”. You will get the “Create Access key” modal.

Create new access key
Download key file

9. Download the key file and open the file in your favorite text editor. These are your root AWS access keys. Keep them secret and safe.

10. Finally, it’s time to create our send emails service. The service uses Amazon SDK for Go APIs to create and send emails.

First, we need to initialize a couple of constants for the emails.

Contestants for the email stuff

Now, we will create a session for our sending email method. Amazon SDK required session.

Create a session and specify AWS region

In the AWS SDK for Go, a session is an object that contains configuration information for service clients. which you use to interact with AWS services. For example, sessions can include information about the region where requests will be sent, which credentials to use, or additional request handlers. Whenever you create a service client, you must specify a session. For more information about sessions, see the session package in the AWS SDK for Go API Reference.

Reference: https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/sessions.html

The SendEmail method will use the recipient, subject, HTML body, sender and our created session.

We now ready to send our email.

Send email using AWS SDK for Go

Here you can find full codebase on GitHub.

Boom check your email inbox. We successfully send email using AWS SDK for Go.

Further reading

https://docs.aws.amazon.com/ses/latest/DeveloperGuide/Welcome.html

Conclusion

I hope you enjoyed the tutorial. Let me know if you have any suggestion on my post in the comments. Thank you for going through this lengthy post. I will be glad if you can share your thoughts with me on Twitter.

You can find it on GitHub.

If you’re looking for a developer or considering starting a new project, I am ready to help! Feel free to DM me on Twitter.

--

--

Nafis Faysal
Codephilics

Software Engineer — Writer — Open Source Enthusiast — Startup Enthusiast. Reach me out in https://www.linkedin.com/in/nafisfaysal for fast response :)