Example usage for com.amazonaws.services.simpleemail.model SendEmailRequest setSource

List of usage examples for com.amazonaws.services.simpleemail.model SendEmailRequest setSource

Introduction

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

Prototype


public void setSource(String source) 

Source Link

Document

The email address that is sending the email.

Usage

From source file:com.github.trask.sandbox.mail.impl.AmazonMailService.java

License:Apache License

public Future<Void> sendMail(String from, String to, String subject, String htmlBody, String textBody) {

    logger.debug("sendMail(): from={}", from);
    logger.debug("sendMail(): to={}", to);
    logger.debug("sendMail(): subject={}", subject);
    logger.debug("sendMail(): htmlBody={}", htmlBody);
    logger.debug("sendMail(): textBody={}", textBody);

    Body body = new Body(new Content(textBody)).withHtml(new Content(htmlBody));
    Message message = new Message(new Content(subject), body);

    SendEmailRequest sendEmailRequest = new SendEmailRequest();
    sendEmailRequest.setSource(from);
    sendEmailRequest.setDestination(new Destination(Collections.singletonList(to)));
    sendEmailRequest.setMessage(message);
    Future<SendEmailResult> future = simpleEmailServiceAsync.sendEmailAsync(sendEmailRequest);
    return new VoidFutureWrapper(future);
}

From source file:org.apache.camel.component.aws.ses.SesProducer.java

License:Apache License

private SendEmailRequest createMailRequest(Exchange exchange) {
    SendEmailRequest request = new SendEmailRequest();
    request.setSource(determineFrom(exchange));
    request.setDestination(determineTo(exchange));
    request.setReturnPath(determineReturnPath(exchange));
    request.setReplyToAddresses(determineReplyToAddresses(exchange));
    request.setMessage(createMessage(exchange));

    return request;
}

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;//  www .  j  ava  2s .  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);
    }

}