I have a "simple" thread class that tries to send messages to an SMTP Server on our LAN. The Transport.connect method connects to the specified host and port successfully (which is not localhost). However, when Transport.send is called using the same Transport object a SendFailed Exception is thrown with the error "Could not connect to SMTP host: localhost, port: 25". I have no idea as to why it is trying to connect to localhost as nothing updates the Transport object between creation and the calling of the Send method (this is shown in the code below).
The constructor contains the following code where member variables are declared as follows:
private Session m_session = null;
private Properties m_props = new Properties();
private Transport m_transport = null;
The problem lies in the run method where I was creating the Transport object and then calling transport.send(...). The send method appears to use the defaults (host:localhost port:25). I changed the code to call transport.sendMessage (...) and this worked. sendMessage obviously uses the settings that were used to create the Transport object.