简体   繁体   English

传输不适用于在java中发送smtp电子邮件

[英]Transport not work for sending smtp email in java

I am using : 我在用 :

transport.connect(getHost(), getPort(), getUsername(), getPassword()); 

to send email, but it always gives me the following exception: 发送电子邮件,但它总是给我以下例外:

class com.sun.mail.smtp.SMTPAddressFailedException: 503 This mail server requires authentication when attempting to send to a non-local e-mail address. class com.sun.mail.smtp.SMTPAddressFailedException:503尝试发送到非本地电子邮件地址时,此邮件服务器需要身份验证。 Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server. 请检查您的邮件客户端设置或联系您的管理员以验证是否为此服务器定义了域或地址。

But actually I have provided the username and password above, and the username and password is right as I tested in thunderbird, it can send email well. 但实际上我提供了上面的用户名和密码,用户名和密码是正确的,因为我在雷鸟测试,它可以很好地发送电子邮件。

So what's my problem ? 那我的问题是什么? Please point me the right direction. 请指出正确的方向。 Thanks 谢谢

When creating the javax.mail.Session, be sure the given properties contain: 创建javax.mail.Session时,请确保给定的属性包含:

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

http://www.oracle.com/technetwork/java/javamail/faq/index.html#smtpauth http://www.oracle.com/technetwork/java/javamail/faq/index.html#smtpauth

I think that you need to talk to the administrators of the mail server to see what is going on. 我认为你需要与邮件服务器的管理员交谈,看看发生了什么。 You might be using the wrong port for instance. 例如,您可能使用了错误的端口。 Or there might be some local policy that you need to observe ... 或者您可能需要遵守一些当地政策......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM