最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
一段带smtp认证的JavaMail代码。
时间:2022-07-02 18:10:37 编辑:袖梨 来源:一聚教程网
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
String mailNeedAuth = CatseyeConfig.getConfig("MailNeedAuth");
String mailUser = CatseyeConfig.getConfig("MailUser");
String mailPassword = CatseyeConfig.getConfig("MailPassword");
if (mailNeedAuth.equals("1")) {
props.put("mail.smtp.auth", "true");
} else {
props.put("mail.smtp.auth", "false");
}
Session session = Session.getDefaultInstance(props, null);
javax.mail.Message msg = new MimeMessage(session);
InternetAddress[] toAddrs = null;
try {
if (recipients != null) {
toAddrs = InternetAddress.parse(recipients, false);
msg.setRecipients(javax.mail.Message.RecipientType.TO, toAddrs);
} else {
throw new Exception("No recipient address specified");
props.put("mail.smtp.host", host);
String mailNeedAuth = CatseyeConfig.getConfig("MailNeedAuth");
String mailUser = CatseyeConfig.getConfig("MailUser");
String mailPassword = CatseyeConfig.getConfig("MailPassword");
if (mailNeedAuth.equals("1")) {
props.put("mail.smtp.auth", "true");
} else {
props.put("mail.smtp.auth", "false");
}
Session session = Session.getDefaultInstance(props, null);
javax.mail.Message msg = new MimeMessage(session);
InternetAddress[] toAddrs = null;
try {
if (recipients != null) {
toAddrs = InternetAddress.parse(recipients, false);
msg.setRecipients(javax.mail.Message.RecipientType.TO, toAddrs);
} else {
throw new Exception("No recipient address specified");
相关文章
- 伊莫雪地盔勇士怎么样 雪地盔勇士角色介绍 10-26
- 星塔旅人初始选什么角色 初始角色选择推荐 10-26
- 逃离鸭科夫收音机在哪获得 收音机获取攻略 10-26
- 逃离鸭科夫蛇形武装怎么解锁 蛇形武装解锁方法 10-26
- 逃离鸭科夫钥匙房在哪里 钥匙房位置一览 10-26
- 二重螺旋武器锻造材料怎么获得 武器锻造材料获取攻略 10-26