Example usage for com.amazonaws.services.simpleemail.model Destination setToAddresses

List of usage examples for com.amazonaws.services.simpleemail.model Destination setToAddresses

Introduction

In this page you can find the example usage for com.amazonaws.services.simpleemail.model Destination setToAddresses.

Prototype


public void setToAddresses(java.util.Collection<String> toAddresses) 

Source Link

Document

The recipients to place on the To: line of the message.

Usage

From source file:org.duracloud.mill.notification.SESNotificationManager.java

License:Apache License

@Override
public void sendEmail(String subject, String body) {
    if (ArrayUtils.isEmpty(this.recipientEmailAddresses)) {
        log.warn("No recipients configured - no one to notify: ignoring...");
        return;//  w  ww . j  av a 2  s .c  o m
    }

    SendEmailRequest email = new SendEmailRequest();
    try {
        Destination destination = new Destination();
        destination.setToAddresses(Arrays.asList(this.recipientEmailAddresses));
        email.setDestination(destination);
        email.setSource("notifications@duracloud.org");
        Message message = new Message(new Content(subject), new Body(new Content(body)));
        email.setMessage(message);
        client.sendEmail(email);
        log.info("email sent: {}", email);
    } catch (Exception e) {
        log.error("failed to send " + email + ": " + e.getMessage(), e);
    }

}