Hi i have write a code for sending mails from my server using java mail
Here is my code
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";
All the details i have provided in my code are correct, i mean the property setting,i have checked it. But unfortunately it shows some error message like Authentication failed
The error message is like this
javax.mail.AuthenticationFailedException
Anybody have any idea about this?
I am using struts2 framework for my project.