1
votes

i have been working on this application that sends email from my local RHEL server. the mail path is: 1. local server to exchange server (outlook, office365) 2. exchange server to mail related domain.

when i test my application from my local PC-WindowsXP it works fine (it sends the mail). but when i try the same from my RHEL server it throws:

com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.office365.com, 25; timeout -1; nested exception is: java.net.SocketException: Network is unreachable

and telnet from the server works fine.(i.e telnet exchange-server-name 25)

my properties are :

        'Properties props = new Properties();
        props.put("mail.transport.protocol", "smtp");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.host", mailServer );
        props.put("mail.smtp.port", "25");
        props.put("mail.smtp.starttls.enable", "true");'

PS: 1. i tried updating the mail.jar, started TLS(using starttls), 2. tried enabling ssl(i.e props.put("mail.smtp.ssl.enable", "true");) while using port 465. 3. tried setting the smtp type to TLS using port 587.

all suggestions will be appreciated.

1

1 Answers

0
votes

See the JavaMail connection debugging tips, but it looks like you have a basic networking problem preventing access from your server to the mail server, perhaps because of a firewall.