I have a Java program which uses javax.mail to send an SMTP message. This program WORKS FINE on a Linux box, I want to emphasize that beforehand. When I try this same code on my Windows 7 x64 box, I get this error:
send failed, exception: javax.mail.MessagingException: Could not connect to SMTP host: smtp.west.cox.net, port: 25; nested exception is: java.net.SocketException: Network is unreachable: connect
Here is the code:
Session session = Session.getInstance(props, null); MimeMessage msg = new MimeMessage(session); msg.setFrom(); msg.setRecipients(Message.RecipientType.TO, props.getProperty("mail.to", "email@example.com")); msg.setSubject(mySubject); msg.setSentDate(new Date()); msg.setContent(sBuf.toString(), "text/html"); Transport.send(msg);
This program pretty much uses defaults for everything. It works fine on another box on the same network. It uses the same settings that I use for my regular mail client, which works fine. There is something on THIS Windows box that is blocking SMTP, but only for Java.
I have Symantec (Norton) 360 installed. Turning it off makes no difference, but rebooting into Safe Mode (which disables almost everything) allows the program to work and send mail just fine.
So, to recap:
- The program code works.
- The settings are correct.
- SMTP works for Windows Mail and is only blocked for Java on this Windows machine.
Before I spend another day tearing things apart and uninstalling/reinstalling, I wondered if anyone had any advice on fixing this?