http://qs321.pair.com?node_id=535063

diggernz has asked for the wisdom of the Perl Monks concerning the following question:

I have written a program to handle bulk mail outs to a client database. There could be upto 1000 emails sent out at a given email campaign. Clients HAVE subscribed to this service. What technique can I use to reduce network activity. When this program is run, the network becomes exhausted. I have added a loop to pause after a given number of mailouts. This isn't solving the problem. Is there any other techniques you suggest? Thank you

Replies are listed 'Best First'.
Re: Bulk Email Load balancing
by tirwhan (Abbot) on Mar 08, 2006 at 07:00 UTC

    Take a look at Mail::BulkMail, that'll combine messages going to different local parts at the same domain into one send and thus significantly cut down on the number of deliveries that need to be made. Also, consider installing a caching DNS server to reduce the number of external DNS requests that need to be made.


    All dogma is stupid.
Re: Bulk Email Load balancing
by TedPride (Priest) on Mar 08, 2006 at 01:00 UTC
    Am I correct that the problem is the number of copies of the same email stacking up on the mail server, waiting to be sent? Obviously, slowing the rate you send emails at won't fix this, unless none of them have problems and the mail server sends faster than it receives. What you need is an intermediary utility that collects all emails and queues them only as fast as the mail server can handle sends. Perhaps you can add each email body to a database table along with the set of addresses it needs to go to (many to one relationship in second table?), then have an intermediary utility perform all the sends at some rate determined by how much the mail server can handle. This way you don't have the mail server clogged with thousands of copies of the same email while you wait for it to be sent, and you don't have multiple emails stacking on top of one another when different people want to send at the same time.
Re: Bulk Email Load balancing
by helphand (Pilgrim) on Mar 08, 2006 at 04:52 UTC

    1000 emails is not a lot of mail. Certainly not enough to saturate a network unless each of the emails is huge. Is the smtp server you are relaying through local or somewhere remote over a slow connection?

    Scott

Re: Bulk Email Load balancing
by spiritway (Vicar) on Mar 08, 2006 at 05:06 UTC

    I think that some of the servers respond to large (for some value of "large") numbers of e-mails being sent through them, by deliberately slowing down the rate at which the messages are sent. The theory is that for a legitimate run of a few dozen or a few hundred, it isn't going to make that much difference - the delay isn't going to do any harm. To a spammer, it will make the connection almost useless. You may be running into a situation like this.

Re: Bulk Email Load balancing
by diggernz (Sexton) on Mar 10, 2006 at 11:03 UTC
    Thanks for your replies
    We are using an internal DNS and mail server (merak mail server). I am currently looping through a database and sending the emails. During the sending phase the network becomes very sluggish! Perhaps I need to adjust my wait() function and loop iterations to reach the potential of our mail server and ethernet capacity.