sysad 给了我这个,因为我无法使用我们的 SMTP 服务器。
堆栈跟踪:
javax.mail.MessagingException: Could not connect to SMTP host: mail.value-exch.com, port: 25, response: -1
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1270)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
at javax.mail.Service.connect(Service.java:275)
at javax.mail.Service.connect(Service.java:156)
at javax.mail.Service.connect(Service.java:105)
at javax.mail.Transport.send0(Transport.java:168)
at javax.mail.Transport.send(Transport.java:98)
除了这些我还应该添加什么吗?喜欢直升机吗?
properties.setProperty("mail.smtp.host", host);
properties.setProperty("mail.smtp.port", port);
我将问题解决为: 如果发件人电子邮件地址的服务器部分是 xyz.com 例如([email protected]) 然后添加这个属性
props.put("mail.smtp.localhost", "xyz.com");
与我完美合作。