我曾经运行一个服务器应用程序,每 2 小时发送一封电子邮件,但有时我会收到以下错误:
Não foi possível enviar a mensagem.
Mensagem: com.sun.mail.smtp.SMTPSendFailedException: 550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1)
Jan 07, 2013 1:00:32 PM job_hidrojato.comunicacao.email.Email run
SEVERE: null
com.sun.mail.smtp.SMTPSendFailedException: 550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1)
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1388)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:959)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)
at javax.mail.Transport.send0(Transport.java:169)
at javax.mail.Transport.send(Transport.java:98)
at job_hidrojato.comunicacao.email.Email.run(Email.java:186)
at java.lang.Thread.run(Thread.java:722)
我已经尝试使用下面的代码显式定义 mail.smtp.localhost,其中“HADES”是我的服务器的主机名,但它不起作用。
props.put("mail.smtp.localhost", "HADES");
此更改后生成的错误日志是相同的,因此我认为问题不在于主机名参数。我已经阅读了下面的链接,但同样没有用,所以我没有其他方法来解决这个问题,任何帮助将不胜感激:)
最佳答案
如果你查找RFC2811第 4.1.1.1 节说(强调我的):
These commands are used to identify the SMTP client to the SMTP server. The argument field contains the fully-qualified domain name of the SMTP client if one is available. In situations in which the SMTP client system does not have a meaningful domain name (e.g., when its address is dynamically allocated and no reverse mapping record is available), the client SHOULD send an address literal (see section 4.1.3), optionally followed by information that will help to identify the client system.
名称 HADES
不是完全限定的域名(主机名+域,例如 www.example.com
,某些 FQDN 定义还需要在end (即 www.example.com.
但我不确定 SMTP 是否需要)。如果您没有 FQDN,则应使用地址文字(请参阅第 4.1.3 节“地址”)文字),基本上就是 IP 地址。
还要确保您的 SMTP 服务器没有主动限制对未知或未经身份验证的主机的访问。
关于JavaMail - HELO 名称无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14199677/