Specifying SMTP port with JavaMail
843830Oct 19 2006 — edited Oct 20 2006Hi,
I am trying to specify a non-default port for SMTP server when using JavaMail, but JavaMail seems to ignore my settings for the specific port. Regardless of my port setting, it seems to always use port 25 to connect to the SMTP server.
I am using JavaMail 1.4ea and I specify the SMTP port as following:
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.host", mailhost);
props.put("mail.smtp.port", smtpPort);
Regardless of what the smtpPort is above, JavaMail always connects to port 25 as shown in the debug output below:
DEBUG: setDebug: JavaMail version 1.4ea
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "test.server.com", port 25, isSSL false
----------
Has anyone seen this behavior ? Is there a different way to specify an alternative port for the SMTP server ?
Thanks.