什么可能导致 SMTPSenderFailedException: 501 5.1.7 Invalid address using java mail?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22260110/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What could be causing SMTPSenderFailedException: 501 5.1.7 Invalid address using java mail?
提问by user26270
Unfortunately, this is at a customer site, so we can't debug. Apparently it's been verified that both the to and from emails are valid. They are apparently using 'open authentication' because it is behind their firewall, so in that case our Properties and Session looks like this:
不幸的是,这是在客户现场,所以我们无法调试。显然,已经验证了 to 和 from 电子邮件都是有效的。他们显然在使用“开放式身份验证”,因为它在他们的防火墙后面,所以在这种情况下,我们的属性和会话如下所示:
Properties props = new Properties();
props.put("mail.smtp.host", configuredHost);
props.put("mail.smtp.port", configuredPort);
props.put("mail.smtp.auth.login.disable", "true");
Session session = Session.getDefaultInstance(props, null);
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(fromEmail));
message.setRecipient(Message.RecipientType.TO, new InternetAddress(toEmail));
message.setSubject(subject);
message.setContent(messageBody, "text/html");
message.setSentDate(new Date());
This code is in use at other sites, and working. So what issue in their environment could be causing this?
此代码已在其他站点使用,并且正在运行。那么他们环境中的什么问题可能导致这种情况?
回答by Bill Shannon
The server disagrees with you about whether the address is valid.
服务器不同意你关于地址是否有效。
You didn't include the code where you send the message so I can't tell if you're authenticating to the server. If you're not, that may be why the server is rejecting your address.
您没有包含发送消息的代码,因此我无法判断您是否正在对服务器进行身份验证。如果不是,这可能就是服务器拒绝您的地址的原因。