0

Am trying to read mails from our mail server using Javamail api. The program works fine when am running it on eclipse in windows on my local system. When i move the same code to our linux environment it gets connection timed out error.

Do i need to install some package on linux or anything? I believe the port should be open else i wont be able to connect from my local network?

The code am using is as below:

properties.setProperty("mail.store.protocol", "imaps");
properties.put("mail.imaps.ssl.trust", "*");
session = Session.getInstance(properties, null);
store = session.getStore();
store.connect(mailServerName, userName, password);
pranav
  • 421
  • 1
  • 11
  • 27

1 Answers1

1

You have first to check if you allowed to connect to your mail server from your lunix host , by issuing telnet like this : telnet host portcommand , some times it is either blocked by firewall or network antivirus. also you may behind a proxy server (You have to check all the above with your network admin).

In case you are behind a proxy server, you have to set the proxy settings and credntials for the JVM. For this , look at answer at Chris Carruthers answer here.

Community
  • 1
  • 1
Jalal Kiswani
  • 738
  • 5
  • 11
  • See also the [connection debugging tips in the JavaMail FAQ](http://www.oracle.com/technetwork/java/javamail/faq/index.html#condebug). – Bill Shannon Jun 22 '16 at 23:36
  • We came to know from admin that we didn't have access to the mail server. – pranav Jun 23 '16 at 12:28