DEBUG: setDebug: JavaMail version 1.4.4
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "smtp.server.com", port 25, isSSL false
220 smtp.server.com ESMTP Postfix (Ubuntu)
DEBUG SMTP: connected to host "smtp.server.com", port: 25
EHLO MYPC
250-smtp.server.com
250-PIPELINING
250-SIZE 20480000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "SIZE", arg "20480000"
DEBUG SMTP: Found extension "VRFY", arg ""
DEBUG SMTP: Found extension "ETRN", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: use8bit false
MAIL FROM:<DoNotReply@example.com>
250 2.1.0 Ok
RCPT TO:<someone@domain.com>
450 4.7.1 Client host rejected: cannot find your hostname, [172.17.9.70]
DEBUG SMTP: Valid Unsent Addresses
DEBUG SMTP: someone@domain.com
DEBUG SMTP: Sending failed because of invalid destination addresses
RSET
250 2.0.0 Ok
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 450 4.7.1 Client host rejected: cannot find your hostname, [172.17.9.70]
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1835)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1098)
at javax.mail.Transport.send0(Transport.java:195)
at javax.mail.Transport.send(Transport.java:124)
at defaultsrc.SendMail.main(SendMail.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 450 4.7.1 Client host rejected: cannot find your hostname, [172.17.9.70]
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1700)
... 9 more
QUIT
221 2.0.0 Bye
以上ip 172.17.9.70是我的计算机局域网IP,MYPC是我的主机名。它似乎比邮件服务器成功连接。但不知道为什么它会说'#34;客户主机被拒绝&#34;。邮件服务器不需要任何身份验证并使用端口25.任何人都可以帮助我吗??
答案 0 :(得分:0)
我会回应另一位评论者,并建议在服务器故障上提出这个问题可能会更好......但我的猜测是这是一个DNS问题。 MX正在从您的IP地址查找您的主机名而没有找到任何内容(“找不到您的主机名”)。见https://en.wikipedia.org/wiki/Forward-confirmed_reverse_DNS
答案 1 :(得分:0)
我遇到了相同的错误,来到这里寻求解决方案。 经过一番挖掘之后,我想出了以下代码,在我的情况下可以正常工作:
String recipient = "recipient@example.com";
String sender = "sender@example.com";
Session session = Session.getDefaultInstance(new Properties());
try {
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(sender));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject("TEST SUBJECT");
message.setText("TEST BODY");
Transport transport = session.getTransport("smtp");
transport.connect("<smtp.host>", "<smtp.user>", "<smtp.password>");
message.saveChanges();
transport.sendMessage(message, new Address[]{new InternetAddress(recipient)});
Transport.send(message);
} catch (MessagingException mex) {
mex.printStackTrace();
}
也许有人会发现它有用:)