本文整理汇总了Java中com.amazonaws.services.simpleemail.model.Destination类的典型用法代码示例。如果您正苦于以下问题:Java Destination类的具体用法?Java Destination怎么用?Java Destination使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Destination类属于com.amazonaws.services.simpleemail.model包,在下文中一共展示了Destination类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: sendEmail
import com.amazonaws.services.simpleemail.model.Destination; //导入依赖的package包/类
/**
* Send email.
*
* @param eMsg the e msg
* @return true, if successful
*/
public boolean sendEmail(EmailMessage eMsg) {
SendEmailRequest request = new SendEmailRequest().withSource(eMsg.getFromAddress());
Destination dest = new Destination().withToAddresses(eMsg.getToAddresses());
dest.setCcAddresses(eMsg.getToCcAddresses());
request.setDestination(dest);
Content subjContent = new Content().withData(eMsg.getSubject());
Message msg = new Message().withSubject(subjContent);
Content textContent = new Content().withData(eMsg.getTxtMessage());
Body body = new Body().withText(textContent);
if (eMsg.getHtmlMessage() != null) {
Content htmlContent = new Content().withData(eMsg.getHtmlMessage());
body.setHtml(htmlContent);
}
msg.setBody(body);
request.setMessage(msg);
try {
emailClient.sendEmail(request);
logger.debug(msg);
} catch (AmazonClientException e) {
logger.error(e.getMessage());
return false;
}
return true;
}
开发者ID:oneops,项目名称:oneops,代码行数:32,代码来源:EmailService.java
示例2: send
import com.amazonaws.services.simpleemail.model.Destination; //导入依赖的package包/类
public void send() throws IOException, TemplateException {
client = createClient();
Destination destination = new Destination().withToAddresses(new String[]{email});
Content subject = new Content().withData(SUBJECT);
String bodyContent = createBody();
Content textContent = new Content().withData(bodyContent);
Body body = new Body().withText(textContent);
Message message = new Message()
.withSubject(subject)
.withBody(body);
SendEmailRequest request = new SendEmailRequest()
.withSource(getSender())
.withDestination(destination)
.withMessage(message);
client.sendEmail(request);
}
开发者ID:julianghionoiu,项目名称:tdl-auth,代码行数:18,代码来源:Mailer.java
示例3: sendEmails
import com.amazonaws.services.simpleemail.model.Destination; //导入依赖的package包/类
public void sendEmails(List<String> emailAddresses,
String from,
String subject,
String emailBody) {
Message message = new Message()
.withSubject(new Content().withData(subject))
.withBody(new Body().withText(new Content().withData(emailBody)));
getChunkedEmailList(emailAddresses)
.forEach(group
-> client.sendEmail(new SendEmailRequest()
.withSource(from)
.withDestination(new Destination().withBccAddresses(group))
.withMessage(message))
);
shutdown();
}
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:21,代码来源:SesClient.java
示例4: sendEmail
import com.amazonaws.services.simpleemail.model.Destination; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public EmailResponse sendEmail(EmailRequest emailRequest) {
try {
SendEmailResult result = this.asyncSES.sendEmail(new SendEmailRequest()
.withSource(this.emailConfig.from())
.withDestination(new Destination()
.withToAddresses(emailRequest.getRecipientToList())
.withCcAddresses(emailRequest.getRecipientCcList())
.withBccAddresses(emailRequest.getRecipientBccList()))
.withMessage(new Message()
.withSubject(new Content().withData(emailRequest.getSubject()))
.withBody(new Body().withHtml(new Content().withData(emailRequest.getBody())))));
return new EmailResponse(result.getMessageId(), result.getSdkHttpMetadata().getHttpStatusCode(),
result.getSdkHttpMetadata().getHttpHeaders());
} catch (Exception ex) {
LOGGER.error("Exception while sending email!!", ex);
throw new AwsException(ex.getMessage(), ex);
}
}
开发者ID:AdeptJ,项目名称:adeptj-modules,代码行数:23,代码来源:AwsSesService.java
示例5: sendEmailAsync
import com.amazonaws.services.simpleemail.model.Destination; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void sendEmailAsync(EmailRequest emailRequest) {
try {
// Shall we use the Future object returned by async call?
this.asyncSES.sendEmailAsync(new SendEmailRequest()
.withSource(this.emailConfig.from())
.withDestination(new Destination()
.withToAddresses(emailRequest.getRecipientToList())
.withCcAddresses(emailRequest.getRecipientCcList())
.withBccAddresses(emailRequest.getRecipientBccList()))
.withMessage(new Message()
.withSubject(new Content().withData(emailRequest.getSubject()))
.withBody(new Body().withHtml(new Content().withData(emailRequest.getBody())))),
this.asyncHandler);
} catch (Exception ex) {
LOGGER.error("Exception while sending email asynchronously!!", ex);
}
}
开发者ID:AdeptJ,项目名称:adeptj-modules,代码行数:22,代码来源:AwsSesService.java
示例6: sendMail
import com.amazonaws.services.simpleemail.model.Destination; //导入依赖的package包/类
private void sendMail(final String from, final String to,
final String subjectStr, final String bodyStr) {
// Construct an object to contain the recipient address.
Destination destination = new Destination()
.withToAddresses(new String[] { to });
// Create the subject and body of the message.
Content subject = new Content().withData(subjectStr);
Content textBody = new Content().withData(bodyStr);
Body body = new Body().withText(textBody);
// Create a message with the specified subject and body.
Message message = new Message().withSubject(subject).withBody(body);
// TODO Assemble the email.
// TODO Send the email.
}
开发者ID:markusklems,项目名称:aws-lambda-java-example,代码行数:20,代码来源:LambdaSendMailFunctionHandler.java
示例7: doInBackground
import com.amazonaws.services.simpleemail.model.Destination; //导入依赖的package包/类
protected Void doInBackground(String...messages) {
if( messages.length == 0 ) return null;
// build the message and destination objects
Content subject = new Content( "OpenCaption" );
Body body = new Body( new Content( messages[0] ) );
Message message = new Message( subject, body );
Destination destination = new Destination().withToAddresses( toAddress );
// send out the email
SendEmailRequest request =
new SendEmailRequest( fromVerifiedAddress, destination, message );
// END:asynctask
SendEmailResult result =
// START:asynctask
sesClient.sendEmail( request );
// END:asynctask
Log.d( "glass.opencaption", "AWS SES resp message id:" + result.getMessageId() );
// START:asynctask
return null;
}
开发者ID:coderoshi,项目名称:glass,代码行数:20,代码来源:EmailWebServiceTask.java
示例8: sendEmail
import com.amazonaws.services.simpleemail.model.Destination; //导入依赖的package包/类
@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;
}
开发者ID:Erudika,项目名称:para,代码行数:26,代码来源:AWSEmailer.java
示例9: prepareMessage
import com.amazonaws.services.simpleemail.model.Destination; //导入依赖的package包/类
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;
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:24,代码来源:SimpleEmailServiceMailSender.java
示例10: buildContent
import com.amazonaws.services.simpleemail.model.Destination; //导入依赖的package包/类
/**
* Builds email content to be sent using an email sender.
* @param message instance where content must be set.
* @throws EmailException if setting mail content fails.
*/
@Override
protected void buildContent(Message message) throws EmailException {
Destination destination = new Destination(getTo());
if (getBCC() != null && !getBCC().isEmpty()) {
destination.setBccAddresses(getBCC());
}
if (getCC() != null && !getCC().isEmpty()) {
destination.setCcAddresses(getCC());
}
if (getSubject() != null) {
Content subject = new Content(getSubject());
//set utf-8 enconding to support all languages
subject.setCharset("UTF-8");
message.setSubject(subject);
}
if (getText() != null) {
Body body = new Body();
Content content = new Content(getText());
//set utf-8 enconding to support all languages
content.setCharset("UTF-8");
body.setText(content);
message.setBody(body);
}
}
开发者ID:albertoirurueta,项目名称:irurueta-server-commons-email,代码行数:33,代码来源:AWSTextEmailMessage.java
示例11: determineTo
import com.amazonaws.services.simpleemail.model.Destination; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Destination determineTo(Exchange exchange) {
List<String> to = exchange.getIn().getHeader(SesConstants.TO, List.class);
if (to == null) {
to = getConfiguration().getTo();
}
return new Destination(to);
}
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:SesProducer.java
示例12: emailVerification
import com.amazonaws.services.simpleemail.model.Destination; //导入依赖的package包/类
public static void emailVerification(String name, String email, UUID uuid,
String username, String responseServletUrl, ServletConfig config) throws EmailUtilException {
String fromEmail = config.getServletContext().getInitParameter("return_email");
if (fromEmail == null || fromEmail.isEmpty()) {
logger.error("Missing return_email parameter in the web.xml file");
throw(new EmailUtilException("The from email for the email facility has not been set. Pleaese contact the OpenChain team with this error."));
}
String link = responseServletUrl + "?request=register&username=" + username + "&uuid=" + uuid.toString();
StringBuilder msg = new StringBuilder("<div>Welcome ");
msg.append(name);
msg.append(" to the OpenChain Certification website.<br /> <br />To complete your registration, click on the following or copy/paste into your web browser <a href=\"");
msg.append(link);
msg.append("\">");
msg.append(link);
msg.append("</a><br/><br/>Thanks,<br/>The OpenChain team</div>");
Destination destination = new Destination().withToAddresses(new String[]{email});
Content subject = new Content().withData("OpenChain Registration [do not reply]");
Content bodyData = new Content().withData(msg.toString());
Body body = new Body();
body.setHtml(bodyData);
Message message = new Message().withSubject(subject).withBody(body);
SendEmailRequest request = new SendEmailRequest().withSource(fromEmail).withDestination(destination).withMessage(message);
try {
AmazonSimpleEmailServiceClient client = getEmailClient(config);
client.sendEmail(request);
logger.info("Invitation email sent to "+email);
} catch (Exception ex) {
logger.error("Email send failed",ex);
throw(new EmailUtilException("Exception occured during the emailing of the invitation",ex));
}
}
开发者ID:OpenChain-Project,项目名称:Online-Self-Certification-Web-App,代码行数:32,代码来源:EmailUtility.java
示例13: emailUser
import com.amazonaws.services.simpleemail.model.Destination; //导入依赖的package包/类
public static void emailUser(String toEmail, String subjectText, String msg, ServletConfig config) throws EmailUtilException {
String fromEmail = config.getServletContext().getInitParameter("return_email");
if (fromEmail == null || fromEmail.isEmpty()) {
logger.error("Missing return_email parameter in the web.xml file");
throw(new EmailUtilException("The from email for the email facility has not been set. Pleaese contact the OpenChain team with this error."));
}
if (toEmail == null || toEmail.isEmpty()) {
logger.error("Missing notification_email parameter in the web.xml file");
throw(new EmailUtilException("The to email for the email facility has not been set. Pleaese contact the OpenChain team with this error."));
}
Destination destination = new Destination().withToAddresses(new String[]{toEmail});
Content subject = new Content().withData(subjectText);
Content bodyData = new Content().withData(msg.toString());
Body body = new Body();
body.setHtml(bodyData);
Message message = new Message().withSubject(subject).withBody(body);
SendEmailRequest request = new SendEmailRequest().withSource(fromEmail).withDestination(destination).withMessage(message);
try {
AmazonSimpleEmailServiceClient client = getEmailClient(config);
client.sendEmail(request);
logger.info("User email sent to "+toEmail+": "+msg);
} catch (Exception ex) {
logger.error("Email send failed",ex);
throw(new EmailUtilException("Exception occured during the emailing of a user email",ex));
}
}
开发者ID:OpenChain-Project,项目名称:Online-Self-Certification-Web-App,代码行数:28,代码来源:EmailUtility.java
示例14: emailAdmin
import com.amazonaws.services.simpleemail.model.Destination; //导入依赖的package包/类
public static void emailAdmin(String subjectText, String msg, ServletConfig config) throws EmailUtilException {
String fromEmail = config.getServletContext().getInitParameter("return_email");
if (fromEmail == null || fromEmail.isEmpty()) {
logger.error("Missing return_email parameter in the web.xml file");
throw(new EmailUtilException("The from email for the email facility has not been set. Pleaese contact the OpenChain team with this error."));
}
String toEmail = config.getServletContext().getInitParameter("notification_email");
if (toEmail == null || toEmail.isEmpty()) {
logger.error("Missing notification_email parameter in the web.xml file");
throw(new EmailUtilException("The to email for the email facility has not been set. Pleaese contact the OpenChain team with this error."));
}
Destination destination = new Destination().withToAddresses(new String[]{toEmail});
Content subject = new Content().withData(subjectText);
Content bodyData = new Content().withData(msg.toString());
Body body = new Body();
body.setHtml(bodyData);
Message message = new Message().withSubject(subject).withBody(body);
SendEmailRequest request = new SendEmailRequest().withSource(fromEmail).withDestination(destination).withMessage(message);
try {
AmazonSimpleEmailServiceClient client = getEmailClient(config);
client.sendEmail(request);
logger.info("Admin email sent to "+toEmail+": "+msg);
} catch (Exception ex) {
logger.error("Email send failed",ex);
throw(new EmailUtilException("Exception occured during the emailing of the submission notification",ex));
}
}
开发者ID:OpenChain-Project,项目名称:Online-Self-Certification-Web-App,代码行数:29,代码来源:EmailUtility.java
示例15: emailProfileUpdate
import com.amazonaws.services.simpleemail.model.Destination; //导入依赖的package包/类
/**
* Email to notify a user that their profiles was updated
* @param username
* @param email
* @param config
* @throws EmailUtilException
*/
public static void emailProfileUpdate(String username, String email,
ServletConfig config) throws EmailUtilException {
String fromEmail = config.getServletContext().getInitParameter("return_email");
if (fromEmail == null || fromEmail.isEmpty()) {
logger.error("Missing return_email parameter in the web.xml file");
throw(new EmailUtilException("The from email for the email facility has not been set. Pleaese contact the OpenChain team with this error."));
}
StringBuilder msg = new StringBuilder("<div>The profile for username ");
msg.append(username);
msg.append(" has been updated. If you this update has been made in error, please contact the OpenChain certification team.");
Destination destination = new Destination().withToAddresses(new String[]{email});
Content subject = new Content().withData("OpenChain Certification profile updated [do not reply]");
Content bodyData = new Content().withData(msg.toString());
Body body = new Body();
body.setHtml(bodyData);
Message message = new Message().withSubject(subject).withBody(body);
SendEmailRequest request = new SendEmailRequest().withSource(fromEmail).withDestination(destination).withMessage(message);
try {
AmazonSimpleEmailServiceClient client = getEmailClient(config);
client.sendEmail(request);
logger.info("Notification email sent for "+email);
} catch (Exception ex) {
logger.error("Email send failed",ex);
throw(new EmailUtilException("Exception occured during the emailing of the submission notification",ex));
}
}
开发者ID:OpenChain-Project,项目名称:Online-Self-Certification-Web-App,代码行数:35,代码来源:EmailUtility.java
示例16: emailPasswordReset
import com.amazonaws.services.simpleemail.model.Destination; //导入依赖的package包/类
public static void emailPasswordReset(String name, String email, UUID uuid,
String username, String responseServletUrl, ServletConfig config) throws EmailUtilException {
String fromEmail = config.getServletContext().getInitParameter("return_email");
if (fromEmail == null || fromEmail.isEmpty()) {
logger.error("Missing return_email parameter in the web.xml file");
throw(new EmailUtilException("The from email for the email facility has not been set. Pleaese contact the OpenChain team with this error."));
}
String link = responseServletUrl + "?request=pwreset&username=" + username + "&uuid=" + uuid.toString();
StringBuilder msg = new StringBuilder("<div>To reset the your password, click on the following or copy/paste into your web browser <a href=\"");
msg.append(link);
msg.append("\">");
msg.append(link);
msg.append("</a><br/><br/><br/>The OpenChain team</div>");
Destination destination = new Destination().withToAddresses(new String[]{email});
Content subject = new Content().withData("OpenChain Password Reset [do not reply]");
Content bodyData = new Content().withData(msg.toString());
Body body = new Body();
body.setHtml(bodyData);
Message message = new Message().withSubject(subject).withBody(body);
SendEmailRequest request = new SendEmailRequest().withSource(fromEmail).withDestination(destination).withMessage(message);
try {
AmazonSimpleEmailServiceClient client = getEmailClient(config);
client.sendEmail(request);
logger.info("Reset password email sent to "+email);
} catch (Exception ex) {
logger.error("Email send failed",ex);
throw(new EmailUtilException("Exception occured during the emailing of the password reset",ex));
}
}
开发者ID:OpenChain-Project,项目名称:Online-Self-Certification-Web-App,代码行数:30,代码来源:EmailUtility.java
示例17: sendTextEmail
import com.amazonaws.services.simpleemail.model.Destination; //导入依赖的package包/类
/**
* Method to send a text email.
* @param m email message to be sent.
* @return id of message that has been sent.
* @throws MailNotSentException if mail couldn't be sent.
*/
private String sendTextEmail(AWSTextEmailMessage m)
throws MailNotSentException {
String messageId;
long currentTimestamp = System.currentTimeMillis();
prepareClient();
if (!mEnabled) {
//don't send message if not enabled
return null;
}
try {
synchronized (this) {
//prevents throttling
checkQuota(currentTimestamp);
Destination destination = new Destination(m.getTo());
if (m.getBCC() != null && !m.getBCC().isEmpty()) {
destination.setBccAddresses(m.getBCC());
}
if (m.getCC() != null && !m.getCC().isEmpty()) {
destination.setCcAddresses(m.getCC());
}
//if no subject, set to empty string to avoid errors
if (m.getSubject() == null) {
m.setSubject("");
}
Message message = new Message();
m.buildContent(message);
SendEmailResult result = mClient.sendEmail(new SendEmailRequest(mMailFromAddress, destination,
message));
messageId = result.getMessageId();
//update timestamp of last sent email
mLastSentMailTimestamp = System.currentTimeMillis();
//wait to avoid throwttling exceptions to avoid making any
//further requests
this.wait(mWaitIntervalMillis);
}
} catch (Throwable t) {
throw new MailNotSentException(t);
}
return messageId;
}
开发者ID:albertoirurueta,项目名称:irurueta-server-commons-email,代码行数:53,代码来源:AWSMailSender.java
示例18: send
import com.amazonaws.services.simpleemail.model.Destination; //导入依赖的package包/类
@Override
public CompletableFuture<Boolean> send(Mail mailMessage) throws MailException {
Message message = new Message();
message.setSubject(new Content(mailMessage.getSubject()).withCharset(Charsets.UTF_8.toString()));
message.setBody(new Body(new Content(mailMessage.getText()).withCharset(Charsets.UTF_8.toString())));
Destination destination = new Destination(asList(mailMessage.getTo()));
Optional.ofNullable(mailMessage.getCc())
.filter(cc -> cc.length > 0)
.ifPresent(cc -> destination.setCcAddresses(asList(cc)));
Optional.ofNullable(mailMessage.getBcc())
.filter(cc -> cc.length > 0)
.ifPresent(cc -> destination.setBccAddresses(asList(cc)));
SendEmailRequest sendEmailRequest = new SendEmailRequest(composeSource(mailMessage).toString(),
destination,
message);
Optional.ofNullable(mailMessage.getReplyTo())
.ifPresent(r -> sendEmailRequest.setReplyToAddresses(asList(r)));
return CompletableFuture.supplyAsync(() -> {
double totalWait = rateLimiter.acquire();
if (totalWait > 5) {
logger.warn("rate limit wait too long: " + totalWait + " seconds");
}
SendEmailResult emailResult = client.sendEmail(sendEmailRequest);
if (logger.isDebugEnabled()) {
logger.debug("sent mail messageId:{}, body:\n{}", emailResult.getMessageId(), mailMessage);
} else {
logger.info("sent mail to {}, messageId:{}", destination, emailResult.getMessageId());
}
return true;
}, executor).handle((result, e) -> {
if (e != null) {
logger.warn("fail send mail to " + destination + ", error:" + e.getMessage());
return false;
}
return true;
});
}
开发者ID:kaif-open,项目名称:kaif,代码行数:44,代码来源:AwsSesMailAgent.java
注:本文中的com.amazonaws.services.simpleemail.model.Destination类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论