When using DefaultJavaMailSender with an existing javax.mail.Session instance (i.e. retrieved from JNDI) it is not possible to leave host and port unconfigured.
My JavaMailSender is configured as follows:
public JavaMailSender mailSender()
mailSession is a preconfigured Session instance retrieved from JNDI registry. I do not know about it's configuration.
When calling the send() method, it tries to connect using the connect(host, port, username, password) method passing the (unconfigured) host and port which defaults to localhost:0 and then fails.
In case the session is supplied, it should call connect() instead.