0

com.sun.mail.smtp.SMTPSendFailedException: 551 This mail server requires authentication before sending mail from a locally hosted domain. Please reconfigure your mail client to authenticate before sending mail.

I am getting the error above when I integrate with the my Java Application running on a Tomcat server

Sending successfully if I use the same properties in separate class with main and run as java application

Why I am not getting this? Thank you in advance.

Matt
  • 17,290
  • 7
  • 57
  • 71
rvd
  • 1
  • 6
  • Suggestion: I would start by troubleshooting your mail server. Especially since you say the same Java class, reading the same properties, works fine outside of Tomcat. Carefully review your mail server configuration (especially with regard to user permissions), enable full (debug) logging, and compare the logs between the "good" case and the "failing" case. Q: What *is* your mail server? – paulsm4 May 26 '15 at 06:57
  • in Good case:EBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc] DEBUG SMTP: useEhlo true, useAuth true DEBUG SMTP: useEhlo true, useAuth true DEBUG SMTP: trying to connect to host "webmail.technobbyte.com", port 25, isSSL false 220 ************************************************************************************* DEBUG SMTP: connected to host "webmail.technobbyte.com", port: 25 – rvd May 26 '15 at 07:04
  • in failing case: DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc] DEBUG SMTP: useEhlo true, useAuth false DEBUG SMTP: trying to connect to host "webmail.technobbyte.com", port 25, isSSL false 220 ************************************************************************************* DEBUG SMTP: connected to host "webmail.technobbyte.com", port: 25 – rvd May 26 '15 at 07:05
  • SMTP is the mail server – rvd May 26 '15 at 07:54

1 Answers1

0
Finally got answer
Here we go: before it was like
`Properties props = new Properties();
props.put("mail.smtp.host", "webmail.technobbyte.com");
props.put("mail.smtp.port", "25");
props.put("mail.smtp.starttls.enable", true);
props.put("mail.smtp.auth", true);`


now i changed to:
`Properties props = new Properties();
props.setProperty("mail.smtp.host", "webmail.technobbyte.com");
props.setProperty("mail.smtp.port", "25");
props.setProperty("mail.smtp.starttls.enable", "true");
props.setProperty("mail.smtp.auth", "true");`
rvd
  • 1
  • 6