Sending multiple mails during 1 connection to the SMTP Server ?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Stephane_RIVIERE
Posted On:   Friday, October 12, 2001 02:46 AM

Hi, I'm writing a mass-mailing program (to be used by a newsletter system) and I have the following problem. I do the following with my Transport : tr.connect(); tr.send(msg1); tr.send(msg2); ... I thought that there would be only 1 connection to the SMTP server but what I get is 1 send = 1 connexion. And that's not really efficient, because I always get the overhead that goes with a new connection :-( Does anyone has a solution to that problem ? Thanks for your help. Skol.    More>>

Hi,


I'm writing a mass-mailing program (to be used by a newsletter system) and I have the following problem.


I do the following with my Transport :

tr.connect();

tr.send(msg1);

tr.send(msg2);

...


I thought that there would be only 1 connection to the SMTP server but what I get is 1 send = 1 connexion.


And that's not really efficient, because I always get the overhead that goes with a new connection :-(


Does anyone has a solution to that problem ?



Thanks for your help.


Skol.

   <<Less

Re: Sending multiple mails during 1 connection to the SMTP Server ?

Posted By:   John_Zukowski  
Posted On:   Friday, October 12, 2001 08:18 PM

Your question is actually already answered in the FAQ. send() is a static method, so makes a separate connection each time.

Re: Sending multiple mails during 1 connection to the SMTP Server ?

Posted By:   nitin_bhatti  
Posted On:   Friday, October 12, 2001 07:11 AM

A better way would be to add the recipients in this manner.

message.addRecipients(Message.RecipientType type,
Address[] addresses)
and then
Transport transport = session.getTransport("smtp");

try{

transport.connect("smtp.yourhost.com", 25, "username", "password");

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

}catch(Exception e){

e.printStackTrace();

}

hope this helps
Nitin

About | Sitemap | Contact