开发者

sending mail through Java

I am facing problem on a centOS server while sending java mails. Getting the following exception.

javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25, response: -1


I used the following command from the command prompt and I got the mail as expected.

echo "testing" | mail -s"test subject" shantanu.oa@gmail.com

The relevant entry from maillog looks like this...

开发者_如何学Python
Mar 28 20:13:16 postfix/smtpd[10120]: fatal: no SASL authentication mechanisms
Mar 28 20:13:17 postfix/master[28163]: warning: process /usr/libexec/postfix/smtpd pid 10120 exit status 1
Mar 28 20:13:17 postfix/master[28163]: warning: /usr/libexec/postfix/smtpd: bad command startup -- throttling
Mar 28 20:26:22 postfix/smtpd[11001]: warning: SASL: Connect to private/auth failed: Connection refused

How do I correct the problem?


From the log entry

Mar 28 20:13:16 postfix/smtpd[10120]: fatal: no SASL authentication mechanisms

I suspect that the problem is on Postfix, of which I'm not an expert. Googling for "fatal: no SASL authentication mechanisms" gives lots of interesting links: maybe have a look here or here.


From the exception it seems like its not able to connect to the host.

Have you tried the telnet stuff?

One more thing to check would be whether the name to IP resolution is taking place properly.If not you can use the IP directly in place of host to see what happens.


does your smtp-server needs authentication? Seems so, because the cmd call with mail works. In default postfix configuration a local user is allowed to send mails without authentication. And your Java application might not be a registered system user on this maschine.

Try to provide username and password in your code to login to the smtp server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜