Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javamail behind proxy

 
Akhilesh Trivedi
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using javamail and behind a proxy.
The mail server, the proxy and the application all three are on same LAN.
If I use outlook to talk to my mail server, it works fine... however with javamail, the following sample code throws exception...




nested exception is:
javax.mail.MessagingException: Could not connect to SMTP host: <some ip here>, port: 25;
nested exception is:
java.net.SocketException: Software caused connection abort: connect
at javax.mail.Transport.send0(Transport.java:219)
at javax.mail.Transport.send(Transport.java:81)
at SendApp.send(SendApp.java:28)
at SendApp.main(SendApp.java:33)
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your proxy server allow the relaying of SMTP? Its going to have to to use JavaMail, and most don't.
 
Akhilesh Trivedi
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks paul. I see it this way, if my outlook express works fine, so should any other mail client, then why not it be my javamail application? Just disabled proxies from IE and outlook still works as is...
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be careful. If you are talking about Exchange servers, Outlook Express does not use SMTP to connect to them, it uses MAPI.


Just disabled proxies from IE and outlook still works as is

The connection setting in IE and the Services defined in Outlook Express are unrelated.

However, if you can connect to an SMTP server via a proxy using an MUA that is actually using SMTP as its connection protocol (phew!) then JavaMail should be able to connect too. How do you know that Outlook is using a proxy? Looking at my version of Outlook, I can only define a mail server, not a proxy (of course the mail server I define may actually be a proxy, but I can't tell that from Outlook).
 
Paul Clapham
Sheriff
Posts: 21321
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure the proxy is responsible for preventing you from connecting to port 25 on the mail server? I ask because some virus-prevention products (McAfee for sure and probably others) will block any outbound access to port 25, to prevent your computer from being used as a spam source. You should be able to turn that off in the product's configuration if that is your problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic