Sending Personalized Bulk Emails using SES Template

1. Introduction

In this article, we’re going to build a java program to send personalized bulk emails using SES template. We will send a personal email to every destination by applying template data.

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

2. Configuring Contacts

We need to configure multiple contacts to send bulk email. Let’s create contact pairs.

List<Pair<String, String>> contacts = new ArrayList<Pair<String, String>>();

// Contacts with email and Name
contacts.add(new Pair<String, String>("", "Satish-CloudTechPro"));
contacts.add(new Pair<String, String>("", "Satish-Gmail"));

Now we have a list of contacts with display names. Later, we’ll use these pairs in the email request.

3. Configuring Default Template Data

SES provides sending default values in case it’s missing in some destinations. Let’s set the default display name.

bulkTemplatedEmailRequest.withDefaultTemplateData(String.format(dataFormat, "UserNameNotAvailable"));

We can only set a single default template data for every request. Default data will be placed in case the destination does not provide that.

4. Prepare Destinations

We can send the same version of the email to multiple addresses. But in our case, we want to send personalized email to every address. Let’s design our code for that.

List<BulkEmailDestination> bulkEmailDestinations = new ArrayList<BulkEmailDestination>();
for (Pair<String, String> contact : contacts) {
    Destination destination = new Destination();
    List<String> toAddresses = new ArrayList<String>();
    BulkEmailDestination bulkEmailDestination = new BulkEmailDestination();
    bulkEmailDestination.setReplacementTemplateData(String.format(dataFormat, contact.getValue()));

We prepared the list of destinations. Each destination contains a single contact. We’ve configured replacement value for every contact to send a personal email.

Currently, AWS SES only supports max 50 destinations. I personally think this limit should be increased. You can create a loop and fire another request if you have more then 50 destinations.

5. Sending Bulk Email

Let’s prepare the bulk email request.

SendBulkTemplatedEmailRequest bulkTemplatedEmailRequest = new SendBulkTemplatedEmailRequest();

We have created a request with destinations.

Now it’s time send the email.

private static void sendEmail() {
    // Prepare destinations
    SendBulkTemplatedEmailRequest bulkTemplatedEmailRequest = new SendBulkTemplatedEmailRequest();
    bulkTemplatedEmailRequest.withDefaultTemplateData(String.format(dataFormat, "UserNameNotAvailable"));
    SendBulkTemplatedEmailResult bulkTemplatedEmailResult = ses.sendBulkTemplatedEmail(bulkTemplatedEmailRequest);

Congratulations! We have successfully sent personalized emails to each destination.

6. Conclusion

In this article, we’ve seen how to send personalized bulk emails using SES template. We’ve created a bulk email request with template data. Also, default template data configured to handle missing inputs from destinations.

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


  1. I often visit your site and have noticed that you don’t update it often.
    More frequent updates will give your page higher rank & authority in google.
    I know that writing posts takes a lot of time, but
    you can always help yourself with miftolo’s tools
    which will shorten the time of creating an article to a couple of seconds.

  2. Heya i’m for the first time here. I came across this board and I
    find It really useful & it helped me out much. I hope to give something back and help
    others like you aided me.

Leave a Reply

Your email address will not be published. Required fields are marked *