我无法通过内部网络通过Exchange邮件服务器发送电子邮件。 它给了我这个例外
Exception in thread "main" javax.mail.MessagingException: Could not connect to SMTP host: exchange.server, port: 25;
nested exception is:
java.net.SocketException: Permission denied: connect
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1961)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:654)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
答案 0 :(得分:0)
在防火墙中为端口25创建例外。如果不存在(端口25用于垃圾邮件可能来自该端口),请尝试更改方法以使用其他端口。相应地配置交换服务器和防火墙。