Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Specifying SMTP port with JavaMail

843830Oct 19 2006 — edited Oct 20 2006
Hi,
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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 17 2006
Added on Oct 19 2006
2 comments
837 views