本文整理汇总了Java中com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient类的典型用法代码示例。如果您正苦于以下问题:Java AmazonSimpleEmailServiceClient类的具体用法?Java AmazonSimpleEmailServiceClient怎么用?Java AmazonSimpleEmailServiceClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AmazonSimpleEmailServiceClient类属于com.amazonaws.services.simpleemail包,在下文中一共展示了AmazonSimpleEmailServiceClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: init
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; //导入依赖的package包/类
/**
* Inits the.
*/
public void init() {
if (this.awsAccessKey == null) {
this.awsAccessKey = System.getenv("AWS_ACCESS_KEY");
if (this.awsAccessKey == null) {
this.awsAccessKey = System.getProperty("com.oneops.aws.accesskey");
}
}
if (this.awsSecretKey == null) {
this.awsSecretKey = System.getenv("AWS_SECRET_KEY");
if (this.awsSecretKey == null) {
this.awsSecretKey = System.getProperty("com.oneops.aws.secretkey");
}
}
emailClient = new AmazonSimpleEmailServiceClient(
new BasicAWSCredentials(awsAccessKey, awsSecretKey));
}
示例3: 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));
}
}
示例4: logMailInfo
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; //导入依赖的package包/类
@SuppressWarnings("unused")
private static void logMailInfo(AmazonSimpleEmailServiceClient client, ServletConfig config) {
logger.info("Email Service Name: "+client.getServiceName());
List<String> identities = client.listIdentities().getIdentities();
for (String identity:identities) {
logger.info("Email identity: "+identity);
}
List<String> verifiedEmails = client.listVerifiedEmailAddresses().getVerifiedEmailAddresses();
for (String email:verifiedEmails) {
logger.info("Email verified email address: "+email);
}
GetSendQuotaResult sendQuota = client.getSendQuota();
logger.info("Max 24 hour send="+sendQuota.getMax24HourSend()+", Max Send Rate="+
sendQuota.getMaxSendRate() + ", Sent last 24 hours="+sendQuota.getSentLast24Hours());
}
示例5: 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));
}
}
示例6: 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));
}
}
示例7: 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));
}
}
示例8: 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));
}
}
示例9: initClients
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; //导入依赖的package包/类
private void initClients() {
AWSCredentials credentials = AmazonSharedPreferencesWrapper
.getCredentialsFromSharedPreferences(this.sharedPreferences);
Region region = Region.getRegion(Regions.US_EAST_1);
sesClient = new AmazonSimpleEmailServiceClient(credentials);
sesClient.setRegion(region);
}
示例10: EmailWebServiceTask
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; //导入依赖的package包/类
public EmailWebServiceTask( Context context ) {
String accessKey = context.getString(R.string.aws_access_key);
String secretKey = context.getString(R.string.aws_secret_key);
fromVerifiedAddress = context.getString(R.string.aws_verified_address);
toAddress = getAccountEmail( context );
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
sesClient = new AmazonSimpleEmailServiceClient( credentials );
}
示例11: parse_MailSenderWithMinimalConfiguration_createMailSenderWithJavaMail
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; //导入依赖的package包/类
@Test
public void parse_MailSenderWithMinimalConfiguration_createMailSenderWithJavaMail() throws Exception {
//Arrange
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());
//Act
AmazonSimpleEmailServiceClient emailService = context.getBean(getBeanName(AmazonSimpleEmailServiceClient.class.getName()), AmazonSimpleEmailServiceClient.class);
MailSender mailSender = context.getBean(MailSender.class);
//Assert
assertEquals("https://email.us-west-2.amazonaws.com", getEndpointUrlFromWebserviceClient(emailService));
assertTrue(mailSender instanceof JavaMailSender);
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:16,代码来源:SimpleEmailServiceBeanDefinitionParserTest.java
示例12: parse_MailSenderWithRegionConfiguration_createMailSenderWithJavaMailAndRegion
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; //导入依赖的package包/类
@Test
public void parse_MailSenderWithRegionConfiguration_createMailSenderWithJavaMailAndRegion() throws Exception {
//Arrange
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-region.xml", getClass());
//Act
AmazonSimpleEmailServiceClient emailService = context.getBean(getBeanName(AmazonSimpleEmailServiceClient.class.getName()), AmazonSimpleEmailServiceClient.class);
MailSender mailSender = context.getBean(MailSender.class);
//Assert
assertEquals("https://email.eu-west-1.amazonaws.com", getEndpointUrlFromWebserviceClient(emailService));
assertTrue(mailSender instanceof JavaMailSender);
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:16,代码来源:SimpleEmailServiceBeanDefinitionParserTest.java
示例13: ClassPathXmlApplicationContext
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; //导入依赖的package包/类
@Test
public void parse_MailSenderWithRegionProviderConfiguration_createMailSenderWithJavaMailAndRegionFromRegionProvider() throws Exception {
//Arrange
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-regionProvider.xml", getClass());
//Act
AmazonSimpleEmailServiceClient emailService = context.getBean(getBeanName(AmazonSimpleEmailServiceClient.class.getName()), AmazonSimpleEmailServiceClient.class);
MailSender mailSender = context.getBean(MailSender.class);
//Assert
assertEquals("https://email.ap-southeast-2.amazonaws.com", getEndpointUrlFromWebserviceClient(emailService));
assertTrue(mailSender instanceof JavaMailSender);
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:16,代码来源:SimpleEmailServiceBeanDefinitionParserTest.java
示例14: parse_MailSenderWithCustomSesClient_createMailSenderWithCustomSesClient
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; //导入依赖的package包/类
@Test
public void parse_MailSenderWithCustomSesClient_createMailSenderWithCustomSesClient() throws Exception {
//Arrange
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-ses-client.xml", getClass());
//Act
AmazonSimpleEmailServiceClient emailService = context.getBean("emailServiceClient", AmazonSimpleEmailServiceClient.class);
MailSender mailSender = context.getBean(MailSender.class);
//Assert
assertSame(emailService, ReflectionTestUtils.getField(mailSender, "emailService"));
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:14,代码来源:SimpleEmailServiceBeanDefinitionParserTest.java
示例15: sendSimpleMessage
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient; //导入依赖的package包/类
@Test
public void sendSimpleMessage() throws Exception {
AmazonSimpleEmailServiceClient sesClient = provider.getClient();
Assume.assumeNotNull("AWS client not null", sesClient);
WildFlyCamelContext camelctx = new WildFlyCamelContext();
camelctx.getNamingContext().bind("sesClient", sesClient);
camelctx.addRoutes(new RouteBuilder() {
public void configure() {
from("direct:start")
.to("aws-ses://" + SESUtils.FROM + "?amazonSESClient=#sesClient");
}
});
camelctx.start();
try {
Exchange exchange = ExchangeBuilder.anExchange(camelctx)
.withHeader(SesConstants.SUBJECT, SESUtils.SUBJECT)
.withHeader(SesConstants.TO, Collections.singletonList(SESUtils.TO))
.withBody("Hello world!")
.build();
ProducerTemplate producer = camelctx.createProducerTemplate();
Exchange result = producer.send("direct:start", exchange);
String messageId = result.getIn().getHeader(SesConstants.MESSAGE_ID, String.class);
Assert.assertNotNull("MessageId not null", messageId);
} finally {
camelctx.stop();
}
}