最新下载
热门教程
- 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");
相关文章
- 王者荣耀守护天痕战令怎么样 王者荣耀守护天痕荣耀战令介绍 04-25
- 王者荣耀镜青焰无极怎么样 王者荣耀镜青焰无极战令皮肤介绍 04-25
- 王者荣耀项羽苍威无极怎么样 王者荣耀项羽苍威无极战令皮肤介绍 04-25
- 王者荣耀镜赤羽无极怎么样 王者荣耀镜赤羽无极战令皮肤介绍 04-25
- 蛋仔派对蛋糕大作战新地图怎么样 蛋仔派对蛋糕大作战新技能介绍 04-25
- 鸦卫奇旅修改器在哪下载 04-25