Archived Forum Post

Index of archived forum posts

Question:

Mailman objects for more than one email sending

May 27 '13 at 09:21

Hi,

i have one more than 1 mail to send ,for each email i need to define new mailman object or i can reuse existing like below

mailman mm=new mailman(); int totalmails=3; for(int i=0;i<totalmails,;i++) { Email em=new Email(); mailman.sendmail(email); } or like below

int totalmails=3; for(int i=0;i<totalmails,;i++) { mailman mm=new mailman(); Email em=new Email(); mailman.sendmail(email); }

Thanks and Regards, Harish Chepuri.


Answer

It's far more efficient to use the same mailman object for multiple emails. This way the same connection to the SMTP server will be used for each email.