为了账号安全,请及时绑定邮箱和手机立即绑定
Java 发邮件

public class SendEmail2 {


/**

 *

 *

 */

public static void main(String[] args) throws Exception {

Properties props = new Properties();

props.setProperty("mail.smtp.auth", "true");// 必须 普通客户端

props.setProperty("mail.transport.protocol", "smtp");// 必须选择协议

props.setProperty("mail.host", "smtp.163.com");

Session session = Session.getDefaultInstance(props,

new Authenticator() {


protected PasswordAuthentication getPasswordAuthentication() {

return new PasswordAuthentication("uyikuy54@163.com", "dfw678631");

}

});

session.setDebug(true);

Message msg = new MimeMessage(session);

msg.setFrom(new InternetAddress("uyikuy54@163.com"));

msg.setSubject("hello");

msg.setRecipients(RecipientType.TO, InternetAddress.parse("54354526@qq.com"));

msg.setContent("<a style='color: #ef027c;' href='http://www.naver.com'>韩国网站</a>", "text/html;charset=utf-8");

Transport.send(msg);


}


正在回答

1 回答

???
0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号