Java Mail mystery - SMTP blocked?

The problem is due to the IPv4/IPv6 preference of Java. Java tries to use IPv6 by default (?) and my ISP does not support IPV6. However, it's enabled on my Windows 7 boxes by default.

If you are experiencing similar behavior, you can verify this by going to "Control Panel/Network and Internet/Network Connections", right-clicking your internet connection, and selecting "Status" from the context menu. The Status dialog will display two lines similar to this:

IPv4 Connectivity:  Internet
IPv6 Connectivity:  No Internet access

This is the root of the problem - Java prefers IPv6, which it cannot use to connect to the internet.

To fix this, do either one (or both) of these things:

  1. Disable IPv6 on your Windows 7 box.
  2. Start your java program using this command line option:

    -Djava.net.preferIPv4Stack=true
    

Doing either one of these will fix the problem.


I had the same problem during upgrade form java 1.6 to java 1.7. The problem occured because java 1.7 using IPv6 by default. To fix this, you need to add Java Option like on example below.

Just run this command on Windows cmd:

setx _JAVA_OPTIONS -Djava.net.preferIPv4Stack=true

Synantec EP 12.1 RU5 fixes your issue.

Symantec Endpoint Protection blocks email sent by Java mail client

Fix ID: 3399185

Symptom: The Internet Email Auto-Protect feature of Symantec Endpoint Protection blocks SMTP email sent by a Java mail client.

Solution: Updated the Internet Email Auto-Protect driver to allow processing of IPv4-mapped IPv6 addresses.