开发者

Java Mail Exception

I have currently face a problem when I try to send an email using JavaMail API. The exception I get from my application console is :

"javax.mail.MessagingException: 550 Access denied - Invalid HELO name (S开发者_开发知识库ee RFC2821 4.1.1.1)"

by the way, I have already set my mail.smtp.auth property to true as : props.put("mail.smtp.auth", "true"), but it still fail, does anyone has idea? or face similar problem before ?


A 550 error is often returned by the SMTP server when the sending hostname cannot be inverse resolved to the originating IP address. This allows mail servers a bit of authentication that the sending client is who it says it is. Unfortunately, many test clients - especially systems behind a NAT device - will have originating IP addresses that don't map to any name.

For example, the machine I am typing this on has an unroutable IP address of 192.168.1.103 and my hostname could be so.example.myhouse which works fine because my router pretends that packets from my desk come from (e.g.) 69.59.196.211 which is my WAN address. However, if you use a props.put("mail.from", "me@so.example.myhouse") the SMTP server may try a DNS lookup and obviously fail for my fictional hostname (that is, one that the global DNS doesn't know of).

Even if I used the DNS name which maps to 69.59.196.211 (e.g. stackoverflow.com) the SMTP server may do a reverse DNS lookup to check that 211.196.59.69.in-addr.arpa maps to stackoverflow.com. If that fails, the SMTP server may consider you a spoofer and return a 550.

Finally, your sending client or every host it its IP address block could be blacklisted by the SMTP server for reasons that you have no control over.

Without more context than you probably want to post (names and addresses of the guilty client and server) I can't be sure that it is an SMTP/DNS problem unrelated to Java so you'll have to check those bits yourself. You can skip the Java altogether and telnet smtp-servername 25 and talk to the server yourself. You'll find RFC 2821 helpful should you try.


replace

props.put("mail.smtp.auth", true); 

to

props.put("mail.smtp.auth", "true");

and it works :)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜