javax.mail.MessagingException 501 5.5.4 Invalid domain name
阿新 • • 發佈:2019-04-04
錯誤資訊: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.
- Open a command prompt.
- Type the following command: telnet <mail server name or IP> 25
- You should receive output similar to the following:
220 remote.mailserveraddress.com ESMTPNOTE: 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
- 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.
- You should receive output similar to the following:
- 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. - Type: mail from: <[email protected]> and press Enter.
- Type: rcpt to: <[email protected]> and press Enter.
- Type: data and press Enter.
- Type: Subject: <a subject here> and press Enter.
- Type: This is a test message sent from telnet. and press Enter.
- Type: . and press Enter
The message should be accepted