代碼如下:public?class?MailTool?{
??public?static?void?main(String[]?args)?throws?MessagingException,?GeneralSecurityException?{
????Properties?props?=?new?Properties();
?
????//?開(kāi)啟debug調(diào)試
????props.setProperty("mail.debug",?"true");
????//?發(fā)送服務(wù)器需要身份驗(yàn)證
????props.setProperty("mail.smtp.auth",?"true");
????//?設(shè)置郵件服務(wù)器主機(jī)名
????props.setProperty("mail.host",?"smtp.qq.com");
????//?發(fā)送郵件協(xié)議名稱(chēng)
????props.setProperty("mail.transport.protocol",?"smtp");
?
????MailSSLSocketFactory?sf?=?new?MailSSLSocketFactory();
????sf.setTrustAllHosts(true);
????props.put("mail.smtp.ssl.enable",?"true");
????props.put("mail.smtp.ssl.socketFactory",?sf);
?
????Session?session?=?Session.getInstance(props);
?
????Message?msg?=?new?MimeMessage(session);
????msg.setSubject("seenews?錯(cuò)誤");
????StringBuilder?builder?=?new?StringBuilder();
????builder.append("url?=?"?+?"http://rstyro.top");
????builder.append("\n頁(yè)面爬蟲(chóng)錯(cuò)誤");
????builder.append("\n時(shí)間?"?+?System.currentTimeMillis());
????msg.setText(builder.toString());
????msg.setFrom(new?InternetAddress("1006059906@qq.com"));
?
????Transport?transport?=?session.getTransport();
????transport.connect("smtp.qq.com",?"1006059906@qq.com",?"我的授權(quán)碼");
?
????transport.sendMessage(msg,?new?Address[]?{?new?InternetAddress("210550028@qq.com")?});
????transport.close();
??}
}報(bào)錯(cuò)如下:這是神馬原因?問(wèn)題補(bǔ)充:已開(kāi)啟QQ郵箱的服務(wù)
javamail 用QQ郵箱,報(bào)錯(cuò)
愛(ài)吃豆角的蟲(chóng)子
2016-08-16 16:14:44