本文整理汇总了Java中com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient.sendEmail方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonSimpleEmailServiceClient.sendEmail方法的具体用法?Java AmazonSimpleEmailServiceClient.sendEmail怎么用?Java AmazonSimpleEmailServiceClient.sendEmail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient
的用法示例。
在下文中一共展示了AmazonSimpleEmailServiceClient.sendEmail方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendSimpleMail
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; //导入方法依赖的package包/类
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);
}
}
示例2: emailVerification
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; //导入方法依赖的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));
}
}
示例3: emailUser
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; //导入方法依赖的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));
}
}
示例4: emailAdmin
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; //导入方法依赖的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));
}
}
示例5: emailProfileUpdate
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; //导入方法依赖的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));
}
}
示例6: emailPasswordReset
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; //导入方法依赖的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));
}
}