How to use Java to send SMTP emails with Amazon Simple Email Service (SES)

Tremaine Eto
Mar 15 · 3 min read
Original photo by NeONBRAND on Unsplash; logo by AWS; illustration by Tremaine Eto

So you want to programmatically send emails with Amazon Simple Email Service, or SES for short.

This article concerns how to do exactly that in Java.

What is Amazon Simple Email Service?

The use cases range from transactional ones (like sending password re-set emails, purchase confirmations, and more) to marketing emails (like special offers, coupons, newsletters, and more) to bulk email communication (like notifications, announcements, and more).

The customers of Amazon SES range from Reddit to Netflix to Duolingo, so you know you’re using an email solution that’s good enough for the biggest players in the game.

First, let’s do some set-up

Then, type in SES in the search bar and then click on it in order to go to the SES Console specifically.

Verify the emails you’ll be sending to and from

There will be a button that says Verify a New Email Address. Click on it, and a modal will display.

Fill in the text input with the email you want to verify; remember, you’ll have to do this not only for the email(s) you wish to send from, but also the email(s) you wish to send to!

Then, you’ll want to access the e-mail(s) you enter and then follow the confirmation instructions inside the messages to verify the e-mail address(es).

Get your SES SMTP Credentials

Once there, choose SMTP Settings. Then, select Create My SMTP Credentials. Fill out the field for the IAM User Name:

Courtesy AWS Docs.

Then, click on Show User SMTP Credentials. Copy and paste your credentials somewhere safe, because once you exit out of this window, you won’t be able to view or save them again.

For more information on this step, check out the AWS Docs on this subject.

The Java code

Photo by Michiel Leunens on Unsplash

Now that you’ve verified the e-mail address(es), you can now move onto coding.

Note the SMTP endpoint address. In the example above, I put "email-smtp.us-west-1.amazonaws.com. This could be yours as well, but you’ll have to find your exact address according to your particular API endpoint depending on your AWS region. This AWS doc describes this point a little more.

Assuming you have the correct SMTP endpoint address, verified e-mail address(es), and haven’t exceeded any sending quotas (which starts at 200 messages over a 24-hour period in AWS sandbox accounts), then the above code should be fairly plug-and-play.

I hope that now you have enough information to not only get started with sending e-mails with Amazon Simple Email Service (SES) but also have the code to do so. If you have any questions, then don’t hesitate to reach out in the comment section.

Dev Genius

Coding, Tutorials, News, UX, UI and much more related to development

Sign up for Best Stories

By Dev Genius

The best stories sent monthly to your email. Take a look.

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Tremaine Eto

Written by

Full-time software engineer since 2016. UCLA Computer Science B.S. with Atmospheric and Oceanic Sciences minor, class of ‘16.

Dev Genius

Coding, Tutorials, News, UX, UI and much more related to development

Tremaine Eto

Written by

Full-time software engineer since 2016. UCLA Computer Science B.S. with Atmospheric and Oceanic Sciences minor, class of ‘16.

Dev Genius

Coding, Tutorials, News, UX, UI and much more related to development

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store