Sending email using JSP

后端 未结 3 1528
囚心锁ツ
囚心锁ツ 2020-12-02 02:13

This problem is driving me nuts. I have the following code:



<%@ page import=\"java.util.*\" %>
<%@ page import=\"javax.mai         


        
3条回答
  •  感情败类
    2020-12-02 03:14

    If you do not want to change the preferred IP stack to IPv4, an alternative solution might be to use the IPv6 address for the host in stead of the DHCP name, e.g.:

    String host = "fe80::b84d:1ed2:5329:de87%10";
    

    The reason of the error is indeed that IPv6 is defaulted on Windows starting from JDK 7. When you attempt to connect to an IPv4 address then under the covers it will use an IPv4-mapped IPv6 address (see this blog from the Oracle website). But normally this should be no problem, if your exchange server supports IPv6. However, I ran in a similar issue when sending a mail from Java code through an MS Exchange 2010 Server after switching to JDK 7. The strange thing is that according to this link on MS Technet it supports IPv6. Since I did not want to default the IP stack of our complete application to IPv4, the accepted solution by setting the flag -Djava.net.preferIPv4Stack=true when starting the application was not an option. Thus changing the host name to a valid IPv6 was a better solution in my case. It's not 100% clear to me why this works and not the DHCP name.

提交回复
热议问题