views:

70

answers:

2

I am programming a smtp sender to send large number of distinct emails (not spam). As there are many destination addresses which are from common provider like hotmail.com/gmail.com. I would like to pool the TCP connections in order to reuse the session. Is this a good practise? Or should I disconnect and connect to send distinct mails instead?

As the subscribers are in large amount, the pooled connection might be kept for a long time (e.g. 1 hour), should I actively release the connection at some point?

Last thing confused me is the destination IPs, as I find out that hotmail.com has a lot of mx servers(at least 12). Does it make any different if I send most of emails to only one of the server or separate them and send to all servers?

Sorry to ask several questions at a time, and do appreciate your view and answer.

A: 

Connect, send X emails for target, disconnect. X should IMHO be somewhere around 16 to 64 - someemail servers dont like too many in one connection and will throw you out otherwise.

You should / can order by destination so you dont ahve to keep sessions open too long, and you MUST properly handle forced disconnects.

Use MX records as you please. There is no need to split your emails to multiple target servers.

TomTom
ccppjava
A: 

First IMHO keeping a connection alive when not in use for more than the time it requires to make the said connection is bad. Not only you're keeping it alive for no use, as you might be preventing another user access to the service.

Connecting to an SMTP server is easy enough to make, send the necessary items and close the connection.

If I'm not mistaken, even Outlook opens a connection for each mail it sends.

Paulo Santos
I think you can send multiple emails, just like POP3, you can get many emails.
ccppjava