1. Introduction

In this article, we’ll build a simple program to send a simple email using Simple Email Service (SES).

This article is part of the ‘AWS Simple Email Service‘ series here at CloudTechPro.

2. Configuring Email Addresses

2.1. Verifying Email Addresses

First of all, we need a verified email address. We’ll use this address for sending and receiving email.

If you don’t have verified email, check out AWS’s documentation for verifying email address in SES.

2.2. Configuring Email Address

To run the sample program, you need to replace sample email from your own verified email. Let’s replace the following email from the sample program. You are free to use the same email in both fields.

private static String senderEmail = "satishpandey.soft@gmail.com";
private static String contact = "satish@cloudtechpro.com";

Now, this email will be used as a sender and receiver.

3. Configuring Email

First, we need a destination where we send the email. Let’s configure a destination.

Destination destination = new Destination();
List<String> toAddresses = new ArrayList<String>();

Second, we need a to prepare message. Let’s create an email body.

Body body = new Body();
body.setText(new Content(emailText));
Message message = new Message();
message.setSubject(new Content(subject));

We’ve set a plain text in the email body. If you want to include HTML content, just use setHtml method under Body class.

4. Sending Email

Now, it’s time to check by sending an email. Let’s prepare a request.

SendEmailRequest sendEmailRequest = new SendEmailRequest();
SendEmailResult emailResult = ses.sendEmail(sendEmailRequest);

Now we are ready to send this request. Let’s execute this program and you will receive a message ID in response.

5. Conclusion

In this article, we’ve seen how to send a simple email using Simple Email Service (SES).

As always, sample program can be found over on GitHub.

Sending Simple Email using Simple Email Service
Tagged on:             

Satish Pandey

I am an expert Java Spring Angular developer with 10+ years of rich and varied experience in developing end-to-end Web Applications. I maintain this blog and publish articles in my free time to help the community. Email: satish@cloudtechpro.com

Leave a Reply

Notify of