setSource(source); setDestination(destination); setMessage(message);
/** * <p> * The reply-to email address(es) for the message. If the recipient replies to the message, each reply-to address * will receive the reply. * </p> * * @param replyToAddresses * The reply-to email address(es) for the message. If the recipient replies to the message, each reply-to * address will receive the reply. * @return Returns a reference to this object so that method calls can be chained together. */ public SendEmailRequest withReplyToAddresses(java.util.Collection<String> replyToAddresses) { setReplyToAddresses(replyToAddresses); return this; }
private void sendEmail(String subject, Body body, String... recipients) { Destination destination = new Destination(Arrays.asList(recipients)); Message msg = new Message().withBody(body).withSubject(new Content(subject)); SendEmailRequest request = new SendEmailRequest().withSource(fromAddress) .withDestination(destination) .withMessage(msg); emailService.sendEmail(request); } }
@Override public boolean sendEmail(List<String> emails, String subject, String body) { if (emails != null && !emails.isEmpty() && !StringUtils.isBlank(body)) { final SendEmailRequest request = new SendEmailRequest().withSource(Config.SUPPORT_EMAIL); Destination dest = new Destination().withToAddresses(emails); request.setDestination(dest); Content subjContent = new Content().withData(subject); Message msg = new Message().withSubject(subjContent); // Include a body in both text and HTML formats Content textContent = new Content().withData(body).withCharset(Config.DEFAULT_ENCODING); msg.setBody(new Body().withHtml(textContent)); request.setMessage(msg); Utils.asyncExecute(new Runnable() { public void run() { sesclient.sendEmail(request); } }); return true; } return false; } }
SendEmailRequest sendEmailRequest = new SendEmailRequest(); sendEmailRequest.withSource(push.getFromAddress()); sendEmailRequest.withReturnPath(push.getFromAddress()); sendEmailRequest.withReplyToAddresses(push.getFromAddress()); sendEmailRequest.setDestination(new Destination().withToAddresses(config.getRecipientOverride())); apiMessage = String.format("Request sent to recipient override, %s.", config.getRecipientOverride()); } else { sendEmailRequest.setDestination(new Destination().withToAddresses(push.getToAddress())); Content subjectContent = new Content().withCharset("UTF-8").withData(subject); sendEmailRequest.setMessage(new Message(subjectContent, body));
private SendEmailRequest prepareMessage(SimpleMailMessage simpleMailMessage) { Destination destination = new Destination(); destination.withToAddresses(simpleMailMessage.getTo()); if (simpleMailMessage.getCc() != null) { destination.withCcAddresses(simpleMailMessage.getCc()); } if (simpleMailMessage.getBcc() != null) { destination.withBccAddresses(simpleMailMessage.getBcc()); } Content subject = new Content(simpleMailMessage.getSubject()); Body body = new Body(new Content(simpleMailMessage.getText())); SendEmailRequest emailRequest = new SendEmailRequest(simpleMailMessage.getFrom(), destination, new Message(subject, body)); if (StringUtils.hasText(simpleMailMessage.getReplyTo())) { emailRequest.withReplyToAddresses(simpleMailMessage.getReplyTo()); } return emailRequest; } }
.ifPresent(cc -> destination.setBccAddresses(asList(cc))); SendEmailRequest sendEmailRequest = new SendEmailRequest(composeSource(mailMessage).toString(), destination, message); .ifPresent(r -> sendEmailRequest.setReplyToAddresses(asList(r)));
/** * <p> * The destination for this email, composed of To:, CC:, and BCC: fields. * </p> * * @param destination * The destination for this email, composed of To:, CC:, and BCC: fields. * @return Returns a reference to this object so that method calls can be chained together. */ public SendEmailRequest withDestination(Destination destination) { setDestination(destination); return this; }
/** * <p> * The message to be sent. * </p> * * @param message * The message to be sent. * @return Returns a reference to this object so that method calls can be chained together. */ public SendEmailRequest withMessage(Message message) { setMessage(message); return this; }
Message message = new Message().withSubject(subject).withBody(body); SendEmailRequest request = new SendEmailRequest() .withSource(sourceEmail) .withDestination(destination) .withMessage(message); request = request.withReplyToAddresses();
@Override public boolean sendEmail(List<String> emails, String subject, String body) { if (emails != null && !emails.isEmpty() && !StringUtils.isBlank(body)) { final SendEmailRequest request = new SendEmailRequest().withSource(Config.SUPPORT_EMAIL); Destination dest = new Destination().withToAddresses(emails); request.setDestination(dest); Content subjContent = new Content().withData(subject); Message msg = new Message().withSubject(subjContent); // Include a body in both text and HTML formats Content textContent = new Content().withData(body).withCharset(Config.DEFAULT_ENCODING); msg.setBody(new Body().withHtml(textContent)); request.setMessage(msg); Para.asyncExecute(new Runnable() { public void run() { sesclient.sendEmail(request); } }); return true; } return false; } }
private SendEmailRequest prepareMessage(SimpleMailMessage simpleMailMessage) { Destination destination = new Destination(); destination.withToAddresses(simpleMailMessage.getTo()); if (simpleMailMessage.getCc() != null) { destination.withCcAddresses(simpleMailMessage.getCc()); } if (simpleMailMessage.getBcc() != null) { destination.withBccAddresses(simpleMailMessage.getBcc()); } Content subject = new Content(simpleMailMessage.getSubject()); Body body = new Body(new Content(simpleMailMessage.getText())); SendEmailRequest emailRequest = new SendEmailRequest(simpleMailMessage.getFrom(), destination, new Message(subject, body)); if (StringUtils.hasText(simpleMailMessage.getReplyTo())) { emailRequest.withReplyToAddresses(simpleMailMessage.getReplyTo()); } return emailRequest; } }
/** * <p> * The destination for this email, composed of To:, CC:, and BCC: fields. * </p> * * @param destination * The destination for this email, composed of To:, CC:, and BCC: fields. * @return Returns a reference to this object so that method calls can be chained together. */ public SendEmailRequest withDestination(Destination destination) { setDestination(destination); return this; }
/** * <p> * The message to be sent. * </p> * * @param message * The message to be sent. * @return Returns a reference to this object so that method calls can be chained together. */ public SendEmailRequest withMessage(Message message) { setMessage(message); return this; }
private void sendSimpleMail(List<String> to, List<String> cc, List<String> ci, String object, String content, boolean htmlContent) { Destination destination = new Destination().withToAddresses(to).withBccAddresses(ci).withCcAddresses(cc); Content subject = new Content().withData(object); Content bodyContent = new Content().withData(content); Body body; if (htmlContent) { body = new Body().withHtml(bodyContent); } else { body = new Body().withText(bodyContent); } Message message = new Message().withSubject(subject).withBody(body); SendEmailRequest request = new SendEmailRequest().withSource(from).withDestination(destination).withMessage(message); try { AmazonSimpleEmailServiceClient client = new AmazonSimpleEmailServiceClient(); client.setRegion(region); client.sendEmail(request); } catch (Exception e) { LOGGER.error("Unable to send email to {} with subject '{}'", StringUtils.join(to, ","), subject, e); } }
@Override public boolean sendEmail(List<String> emails, String subject, String body) { if (emails != null && !emails.isEmpty() && !StringUtils.isBlank(body)) { final SendEmailRequest request = new SendEmailRequest().withSource(Config.SUPPORT_EMAIL); Destination dest = new Destination().withToAddresses(emails); request.setDestination(dest); Content subjContent = new Content().withData(subject); Message msg = new Message().withSubject(subjContent); // Include a body in both text and HTML formats Content textContent = new Content().withData(body).withCharset(Config.DEFAULT_ENCODING); msg.setBody(new Body().withHtml(textContent)); request.setMessage(msg); Para.asyncExecute(new Runnable() { public void run() { sesclient.sendEmail(request); } }); return true; } return false; } }
setSource(source); setDestination(destination); setMessage(message);
/** * <p> * The reply-to email address(es) for the message. If the recipient replies to the message, each reply-to address * will receive the reply. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setReplyToAddresses(java.util.Collection)} or {@link #withReplyToAddresses(java.util.Collection)} if you * want to override the existing values. * </p> * * @param replyToAddresses * The reply-to email address(es) for the message. If the recipient replies to the message, each reply-to * address will receive the reply. * @return Returns a reference to this object so that method calls can be chained together. */ public SendEmailRequest withReplyToAddresses(String... replyToAddresses) { if (this.replyToAddresses == null) { setReplyToAddresses(new com.amazonaws.internal.SdkInternalList<String>(replyToAddresses.length)); } for (String ele : replyToAddresses) { this.replyToAddresses.add(ele); } return this; }
@Override void makeSend(String to, String subject, String msg) { String accessKey = config.readString(ConfigProperty.SES_ACCESS_KEY); String secretKey = config.readString(ConfigProperty.SES_SECRET_KEY); if (!Strings.isNullOrEmpty(accessKey)) { Destination destination = new Destination().withToAddresses(to); Content subj = new Content().withData(subject); Content textBody = new Content().withData(msg); Body body = new Body().withHtml(textBody); Message message = new Message().withSubject(subj).withBody(body); SendEmailRequest req = new SendEmailRequest().withSource(config.readString(ConfigProperty.EMAIL_DEFAULT_FROM_NAME) + " <" + config.readString(ConfigProperty.EMAIL_DEFAULT_FROM) + ">") .withDestination(destination).withMessage(message); AmazonSimpleEmailService client = AmazonSimpleEmailServiceClientBuilder.standard() .withRegion(config.readString(ConfigProperty.SES_REGION)) .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey))) .build(); try { client.sendEmail(req); } finally { client.shutdown(); } } else { throw new IllegalStateException("SES Mail provider wasn't configured well."); } }
setSource(source); setDestination(destination); setMessage(message);