dcsimg

I want to use a port other than the default port for SMTP. Can I specify it in JavaMail?

John Zukowski

You can either set the "mail.smtp.port" property in the Properties you pass to the Session object, or specify the port when you connect in the transport:

Transport smtp = Session.getTransport("smtp");
smtp.connect(host, port, username, password);