10/15/2012
SMTPAddressFailedException: 530 5.7.1 Authentication Required
When use java mail API to send emails, this error is solved by adding red line.
Properties props = new Properties();
props.put("mail.smtp.host", "XXX");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "25");
props.put("mail.transport.protocol", "smtp");
props.put("mail.store.protocol", "pop3");
props.put("mail.smtp.username", user);
props.put("mail.smtp.password", password);
props.put("mail.smtp.starttls.enable", "true");
// Session session = Session.getInstance(props, null);
Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("username", "password");
}
});
msg = new MimeMessage(session);
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment