javax.mail.MessagingException 501 5.5.4 Invalid domain name

错误信息:javax.mail.MessagingException 501 5.5.4 Invalid domain name

java 程序发送email失败,但是用telnet发送email成功。

最后排查到是因为有人改了/etc/hosts文件,正常的hosts文件中应有一行是ip和主机名对应内容,如下

192.168.1.80    panda

但是被人改为 192.168.1.80   panda^M

javax.mail底层会读取这一行,并将其发送给邮件服务器,邮件服务器检测到主机名与ip不对应就报这个错误了。

下面为telnet发送email方法:

 Test the connection and send an email

Once the Telnet client has been installed, follow the steps below to test email delivery.

  1. Open a command prompt.
  2. Type the following command: telnet <mail server name or IP> 25
    • You should receive output similar to the following:
      220 remote.mailserveraddress.com ESMTP

      NOTE: Once the telnet session is established, the Backspace and Delete keys do not work. If a typo is made, press Enter and retry the command. In some cases, it may be necessary to close the telnet session and reconnect.

    • If you receive an error similar to Could not open connection to the host, on port 25: Connect failed, this indicates that your machine could not establish a telnet session with the destination server using port 25. If you initially attempted to connect using the destination server's name, try to connect using its IP address instead. If this is successful, you likely have a DNS issue. If you are unable to connect using the destination server's name or IP address, port 25 is being blocked somewhere between your machine and the destination server. The issue is probably due to a firewall on the destination server's end, but it can also be caused by a network misconfiguration or firewall on your end.
    • If you receive output similar to the following:
      554-remote.mailserveraddress.com
      554 Your connection has been blocked due to low sender reputation...
      Connection to host lost.

      The public IP address associated with your mail server has developed a bad reputation. If you recently acquired this IP address, its previous owner likely sent spam from it, and your best option may be to request a different address from your ISP. If this is not feasible, there are other options, but there is not always a quick or easy solution to this issue. The error message may include additional instructions for resolving the issue. If not, this blog entry has a number of suggestions. Unfortunately, it may simply be a matter of waiting for your address's reputation to improve, and this can take considerable time.
  3. Type: EHLO <mail server internet name>
    Replace <mail server internet name> with your mail server's public fully qualified domain name - for instance, mail.dell.com.
  4. Type: mail from: <your_name@yourdomain.com> and press Enter.
  5. Type: rcpt to: <recipient@recipientdomain.com> and press Enter.
  6. Type: data and press Enter.
  7. Type: Subject: <a subject here> and press Enter.
  8. Type: This is a test message sent from telnet. and press Enter.
  9. Type: . and press Enter
    The message should be accepted for delivery.

转载于:https://my.oschina.net/jms0755/blog/3032326

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值