How to test for secure SMTP mail service on a mail server
Posted
by
Vinay S Shenoy
on Stack Overflow
See other posts from Stack Overflow
or by Vinay S Shenoy
Published on 2012-04-16T11:25:10Z
Indexed on
2012/04/16
11:29 UTC
Read the original article
Hit count: 251
I'm working on a project to auto-configure a user's email server settings in Java. I am extracting the mail server from his email address and looking up the MX records of that mail server using the DirContext
class with com.sun.jndi.dns.DnsContextFactory
.
Then I'm opening a Socket
to each server and testing them using a HELO
command and checking the responses.
My problem is that this works only when I test it with the unsecure SMTP port 25. How can I use it with the secure port 465?
I tried using Secure Sockets by using
SSLSocketFactory sslsocketfactory = (SSLSocketFactory)SSLSocketFactory.getDefault();
SSLSocket socket = (SSLSocket)sslsocketfactory.createSocket(mailserver, STANDARD_SMTP_PORT);
But all connections get a timeout exception as follows
alt1.gmail-smtp-in.l.google.com. java.net.ConnectException: Operation timed out
Please help.
© Stack Overflow or respective owner