java 使用 Amazon SES发送电子邮件,有三种方式,具体哪三种请移步这里。

这里只介绍一种:利用Amazon SES 的 SMTP 服务,javax.mail发送邮件。此方法也可以直接用于163邮箱(需要自己开启邮箱的SMTP服务),亲测有效。

1、先将发送邮件的邮箱在Amazon SES里面验证一下,具体验证方法请参考这里。在使用过程中,发送送邮件返回错误状态码具体参考这里。

2、Amazon SES默认是Sandbox模式,需要发送申请production access,要等他们review。

3、代码示例:(代码自行抽取)

package com.iot.task;import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.redis.Redis;import org.quartz.*;
import redis.clients.jedis.Jedis;import javax.mail.*;
import javax.mail.Message;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;import java.io.*;
import java.util.Properties;import java.util.List;public class PushAlarmNotificationTask implements Job {// Replace sender@example.com with your "From" address.// This address must be verified with Amazon SES.private static final String FROM = "";private static final String FROMNAME = "";private static final String TO = "";// Replace smtp_username with your Amazon SES SMTP user name.private static final String SMTP_USERNAME = "";// Replace smtp_password with your Amazon SES SMTP password.private static final String SMTP_PASSWORD = "";// The name of the Configuration Set to use for this message.// If you comment out or remove this variable, you will also need to// comment out or remove the header below.private static final String CONFIGSET = "ConfigSet";// Amazon SES SMTP host name. This example uses the 美国西部(俄勒冈) region.// See https://docs.aws.amazon.com/ses/latest/DeveloperGuide/regions.html#region-endpoints// for more information.private static final String HOST = "email-smtp.us-east-1.amazonaws.com";// The port you will connect to on the Amazon SES SMTP endpoint.private static final int PORT = 587;private static final String SUBJECT = "";private String BODY = String.join(System.getProperty("line.separator"),"");private String Message = "Hello Email";@Overridepublic void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {Transport transport = null;try {// Create a Properties object to contain connection configuration information.Properties props = System.getProperties();props.put("mail.transport.protocol", "smtp");props.put("mail.smtp.port", PORT);props.put("mail.smtp.starttls.enable", "true");props.put("mail.smtp.auth", "true");// Create a Session object to represent a mail session with the specified properties.Session session = Session.getDefaultInstance(props);// Create a message with the specified information.MimeMessage msg = new MimeMessage(session);msg.setFrom(new InternetAddress(FROM, FROMNAME));msg.setRecipient(Message.RecipientType.TO, new InternetAddress(TO));msg.setSubject(SUBJECT);BODY = BODY + Message;msg.setContent(BODY, "text/html");// Add a configuration set header. Comment or delete the// next line if you are not using a configuration set//msg.setHeader("X-SES-CONFIGURATION-SET", CONFIGSET);// Create a transport.transport = session.getTransport();// Connect to Amazon SES using the SMTP username and password you specified above.transport.connect(HOST, SMTP_USERNAME, SMTP_PASSWORD);// Send the email.transport.sendMessage(msg, msg.getAllRecipients());sendNum++;} catch (UnsupportedEncodingException | MessagingException ex) {ex.printStackTrace();} finally {// Close and terminate the connection.try {transport.close();} catch (MessagingException e) {e.printStackTrace();}}}}

java 使用 Amazon SES 发送电子邮件相关推荐

  1. 亚马逊ses如何发qq_使用Amazon SES发送电子邮件

    亚马逊ses如何发qq by Kangze Huang 黄康泽 使用Amazon SES发送电子邮件 (Sending emails with Amazon SES) 完整的AWS Web样板-教程3 ...

  2. php ses 发送邮件,php – 无法使用Amazon SES发送电子邮件

    我正在使用AWS PHP SDK.我有以下代码使用SES发送电子邮件: $ses = new AmazonSES(...); $response = $ses->send_email('ubun ...

  3. 亚马逊ses如何发qq_亚马逊ses发送电子邮件

    亚马逊ses如何发qq SES (Simple Email Service) is, as the name suggests, a very simple service to enable pro ...

  4. php ses 发送邮件,使用PHP SDK从Amazon SES发送HTML邮件

    我正在开发一项从AWS SES服务发送电子邮件的服务.我已经能够发送纯文本邮件,但我需要在其中一个案例中发送丰富的 HTML邮件.这是我使用的代码: header("MIME-Version ...

  5. java smtp_java通过smtp发送电子邮件

    packagecom.sm.modules.oa.web;importjavax.mail.Session;importjavax.mail.Transport;importjavax.mail.in ...

  6. Amazon SES 邮件发送服务

    1. 进入AWS后台,在服务中找到SES(Simple Email Service)点击. 2. 进入SES主页,点击左侧导航栏中"SMTP Settings". 3. 进入&qu ...

  7. php ses 发送邮件,使用 Amazon SES API 和 AWS SDK for PHP 版本 3 验证电子邮件身份 - 适用于 PHP 的 AWS 开发工具包...

    AWS 文档中描述的 AWS 服务或功能可能因区域而异.要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门. 本文属于机器翻译版本.若本译文内容与英语原文存在差异,则一律以英文原文为准. 使用 ...

  8. php统计邮件打开率,监控 Amazon SES 电子邮件的打开率、点击率和退回率

    如何监控通过使用 Amazon SES 发送的电子邮件的打开率.点击率和退回率? 上次更新时间:2020 年 12 月 14 日 我想要获得我使用 Amazon Simple Email Servic ...

  9. aws 邮件服务器 接收邮件,Amazon SES

    问:Amazon SES 是否提供 SMTP 终端节点? Amazon SES 提供 SMTP 接口,以实现与能够通过 SMTP 发送电子邮件的应用程序的无缝集成.您可从应用程序直接连接至此 SMTP ...

最新文章

  1. c++小项目:通讯录管理系统
  2. 使用委派调用对象的方法
  3. 9soc sensor与bayer sensor 区别,内外置isp
  4. beyond compare4过期解决方法_面试必备:缓存穿透、雪崩解决方案及缓存击穿的四种解决方案...
  5. setinterval 会被销毁吗_链信全国城市节点竞价活动完美收官,第一批节点总计销毁516600个CCT!...
  6. mac端addr2line的NDK位置和使用
  7. python里面装数据库_python 安装操作 MySQL 数据库.
  8. Linux 中显示所有正在运行的进程
  9. 2019快手内容报告重磅发布:日活突破3亿 点赞量超3500亿
  10. 题目264-国王的魔镜
  11. 发那科服务器显示021,发那科(FANUC)系统报警代码大全
  12. Linux 编译并更换内核
  13. 用微PE安装KALI LINUX到U盘,【U盘安装kali】U盘+kali+pe三合一教程
  14. 分集阶数(diversity order)
  15. 如何用Jquery获取某一个Div的Class或者ID
  16. 项目:机器学习+FLD分类+python图像处理mnist数据集
  17. stm32笔记05——stm32引脚功能分布
  18. 微信小程序JS编写一元三次方程盛金公式解法代码片段
  19. 没听过计算机竞赛,国际信奥赛中国队夺冠!我忍不住再来和大家说说“编程”...
  20. 从零开始学习Linux运维,成为IT领域翘楚(一)

热门文章

  1. PyTorch基础之激活函数模块中Sigmoid、Tanh、ReLU、LeakyReLU函数讲解(附源码)
  2. MYSQL数据库- 修改数据表名称、列名称
  3. FOC学习之路——硬件电路(一)
  4. shell里的json超级工具 jq 高级用法介绍
  5. 使用功耗分析仪,对一款LORA低功耗温度传感器进行功耗评测,评估温度传感器的待机时长,供参考。
  6. 前端基础(HTML、CSS、JS)
  7. 微博2面:微信朋友圈是怎么实现的?
  8. 大学计算机实验图灵机模型与计算机硬件,实验1图灵机模型与计算机硬件系统虚拟拆装实验报告.pdf...
  9. 探索 Android TDD 开发方法
  10. 微信小程序入门教程+案例demo