• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AmazonSimpleEmailServiceClientBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClientBuilder的典型用法代码示例。如果您正苦于以下问题:Java AmazonSimpleEmailServiceClientBuilder类的具体用法?Java AmazonSimpleEmailServiceClientBuilder怎么用?Java AmazonSimpleEmailServiceClientBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AmazonSimpleEmailServiceClientBuilder类属于com.amazonaws.services.simpleemail包,在下文中一共展示了AmazonSimpleEmailServiceClientBuilder类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: makeSend

import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClientBuilder; //导入依赖的package包/类
@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.");
    }
}
 
开发者ID:dmart28,项目名称:gcplot,代码行数:29,代码来源:SESMailProvider.java


示例2: afterPropertiesSet

import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClientBuilder; //导入依赖的package包/类
@PostConstruct
public void afterPropertiesSet() {
  AWSCredentials awsSesCredentials = new BasicAWSCredentials(mailProperties.getAwsAccessKey(),
      mailProperties.getAwsSecretKey());
  this.client = AmazonSimpleEmailServiceClientBuilder.standard()
      .withRegion(Regions.US_EAST_1)
      .withCredentials(new AWSStaticCredentialsProvider(awsSesCredentials))
      .build();
  logger.info("mail agent ready, sender:"
      + mailProperties.getAwsSenderAddress()
      + ", access key:"
      + awsSesCredentials.getAWSAccessKeyId());
}
 
开发者ID:kaif-open,项目名称:kaif,代码行数:14,代码来源:AwsSesMailAgent.java


示例3: createEmailClient

import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClientBuilder; //导入依赖的package包/类
public static AmazonSimpleEmailServiceClient createEmailClient() {
    BasicCredentialsProvider credentials = BasicCredentialsProvider.standard();
    AmazonSimpleEmailServiceClient client = !credentials.isValid() ? null : (AmazonSimpleEmailServiceClient)
            AmazonSimpleEmailServiceClientBuilder.standard()
            .withCredentials(credentials)
            .withRegion("eu-west-1")
            .build();
    return client;
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:10,代码来源:SESUtils.java


示例4: handleRequest

import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClientBuilder; //导入依赖的package包/类
@Override
public Parameters handleRequest(Parameters parameters, Context context) {

    context.getLogger().log("Input Function [" + context.getFunctionName() + "], Parameters [" + parameters + "]");

    try {

        // Create an empty Mime message and start populating it
        Session session = Session.getDefaultInstance(new Properties());
        MimeMessage message = new MimeMessage(session);
        message.setSubject(EMAIL_SUBJECT, "UTF-8");
        message.setFrom(new InternetAddress(System.getenv("EMAIL_FROM")));
        message.setReplyTo(new Address[] { new InternetAddress(System.getenv("EMAIL_FROM")) });
        message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(System.getenv("EMAIL_RECIPIENT")));

        MimeBodyPart wrap = new MimeBodyPart();
        MimeMultipart cover = new MimeMultipart("alternative");
        MimeBodyPart html = new MimeBodyPart();
        cover.addBodyPart(html);
        wrap.setContent(cover);
        MimeMultipart content = new MimeMultipart("related");
        message.setContent(content);
        content.addBodyPart(wrap);

        // Create an S3 URL reference to the snapshot that will be attached to this email
        URL attachmentURL = createSignedURL(parameters.getS3Bucket(), parameters.getS3Key());

        StringBuilder sb = new StringBuilder();
        String id = UUID.randomUUID().toString();
        sb.append("<img src=\"cid:");
        sb.append(id);
        sb.append("\" alt=\"ATTACHMENT\"/>\n");
        
        // Add the attachment as a part of the message body
        MimeBodyPart attachment = new MimeBodyPart();
        DataSource fds = new URLDataSource(attachmentURL);
        attachment.setDataHandler(new DataHandler(fds));
        
        attachment.setContentID("<" + id + ">");
        attachment.setDisposition(BodyPart.ATTACHMENT);
         
        attachment.setFileName(fds.getName());
        content.addBodyPart(attachment);

        // Pretty print the Rekognition Labels as part of the Emails HTML content
        String prettyPrintLabels = parameters.getRekognitionLabels().toString();
        prettyPrintLabels = prettyPrintLabels.replace("{", "").replace("}", "");
        prettyPrintLabels = prettyPrintLabels.replace(",", "<br>");            
        html.setContent("<html><body><h2>Uploaded Filename : " + parameters.getS3Key().replace("upload/", "") + 
                        "</h2><p><b>Detected Labels/Confidence</b><br><br>" + prettyPrintLabels + "</p>"+sb+"</body></html>", "text/html");

        // Convert the JavaMail message into a raw email request for sending via SES
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        message.writeTo(outputStream);
        RawMessage rawMessage = new RawMessage(ByteBuffer.wrap(outputStream.toByteArray()));
        SendRawEmailRequest rawEmailRequest = new SendRawEmailRequest(rawMessage);

        // Send the email using the AWS SES Service
        AmazonSimpleEmailService client = AmazonSimpleEmailServiceClientBuilder.defaultClient();
        client.sendRawEmail(rawEmailRequest);

    } catch (MessagingException | IOException e) {
        // Convert Checked Exceptions to RuntimeExceptions to ensure that
        // they get picked up by the Step Function infrastructure
        throw new AmazonServiceException("Error in ["+context.getFunctionName()+"]", e);
    }

    context.getLogger().log("Output Function [" + context.getFunctionName() + "], Parameters [" + parameters + "]");

    return parameters;
}
 
开发者ID:markwest1972,项目名称:smart-security-camera,代码行数:72,代码来源:SesSendNotificationHandler.java


示例5: AWSEmailer

import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClientBuilder; //导入依赖的package包/类
/**
 * No-args constructor.
 */
public AWSEmailer() {
	sesclient = AmazonSimpleEmailServiceClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(
			new BasicAWSCredentials(Config.AWS_ACCESSKEY, Config.AWS_SECRETKEY))).
			withRegion(Config.AWS_REGION).build();
}
 
开发者ID:Erudika,项目名称:para,代码行数:9,代码来源:AWSEmailer.java



注:本文中的com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClientBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AbstractXmlHttpMessageConverter类代码示例发布时间:2022-05-23
下一篇:
Java AnnotationJmxAttributeSource类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap