在java中发送smtp电子邮件的传输不起作用
我正在使用 :
transport.connect(getHost(), getPort(), getUsername(), getPassword());
发送电子邮件,但它总是给我以下异常:
class com.sun.mail.smtp.SMTPAddressFailedException: 503 此邮件服务器在尝试发送到非本地电子邮件地址时需要身份验证。请检查您的邮件客户端设置或联系您的管理员以验证是否为此服务器定义了域或地址。
但实际上我上面已经提供了用户名和密码,并且我在雷鸟中测试用户名和密码是正确的,可以很好地发送电子邮件。
那么我的问题是什么?请为我指出正确的方向。谢谢
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. 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建 javax.mail.Session 时,请确保给定属性包含:
http://www.oracle.com/technetwork/java/javamail/faq/index.html#smtpauth
When creating the javax.mail.Session, be sure the given properties contain:
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 ...