Simple steps to send emails using Java programming and Amazon SES
There are many use cases where we need to send emails from our applications to customers. We see use cases in e-commerce when a user purchases an item and an order confirmation email has to be sent. In workflow applications, whenever there is a change in process flow, a notification email will be sent.
In this post, we will explain how to send emails from Java code. If you’re new to Java, then you’ll want to cover the basics with Cloud Academy’s Introduction to Java. If you already understand the basics and want to take your skills to the next level, you can dive right into Cloud Academy’s one-stop guide to mastering recent Java platform updates with the Advanced Java Programming Learning Path.
SMTP servers are used to send emails. Therefore, both sender and receiver email desktop-based client applications will be configured to connect with SMTP server. This is applicable in case of web-based email applications as well.
The following is a list of basic requirements to send emails from our Java code and demo code.
We need access to SMTP server to send emails.
We need to generate user credentials to get permission to use SES.
The user has to verify the sender and receiver’s email address in Amazon SES.
Accessing SMTP server
Amazon Simple Email Service (Amazon SES) is the service provided by AWS. This service can be used as SMTP server in our code to send emails. As part of free usage tier Amazon allows you to send more than 60000 mails at free of cost from Amazon EC2 instance.
Verifying email addresses
1. Log into AWS management console. Then select “Amazon SES” service.
Please note that SES service is available in the region you have selected. There are where regions SES service is not offered.