嗨,我有寫代碼,使用Java郵件Java郵件javax.mail.AuthenticationFailedException
這裏發送從我的服務器的郵件是我的代碼
Properties pros = new Properties();
pros.put("mail.smtp.host", "my Ip Adress");
pros.put("mail.smtp.auth", "true");
pros.put("mail.smtp.port", "25");
Session mailSession = Session.getDefaultInstance(pros,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("emailId","password");
}
});
Message message = new MimeMessage(mailSession);
message.setFrom(new InternetAddress("sendingAddress"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("recieverAddress"));
message.setSubject("Testing Subject");
message.setText("Dear Mail Crawler," +
"\n\n No spam to my email, please!");
Transport.send(message);
return "SUCCESS";
所有我在我的代碼中提供的細節正確,我的意思是屬性設置,我已經檢查過它。但不幸的是它表明,如身份驗證一些錯誤信息失敗
的錯誤信息是這樣的
javax.mail.AuthenticationFailedException
任何人對此有什麼想法?
我正在爲我的項目使用struts2框架。
看到類似的問題類似的線程http://stackoverflow.com/ questions/2047942/how-to-resovle-javax-mail-authenticationfailedexception-issue – 2012-02-24 09:19:09