Keeping smtp connections open

Hi,

Is there anyway for one to keeping an smtp connection alive? Every mail I send via smtp sends a QUIT at the end which essentially close the connection on the smtp relay.

Thus when I send a new mail it has to re-establish a connection to the mail server every time, which can take some time.

Does anyone know how to stop the smtp transport client from not sending the quit command prematurely? or a way for the smtp client to use an open connection?

[484 byte] By [rdf2] at [2007-9-26 2:01:27]
# 1

Just create an instance of Transport, and keep using it until you're done sending messages. Something like this:

Transport transport = session.getTransport("smtp");

transport.connect(host, username, password);

transport.sendMessage(message, message.getAllRecipients());

//...

transport.close();

If you use the static method Transport.send(), it will close the connection after each sending.

Hope this helps.

thinkfly at 2007-6-29 8:41:47 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...