Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Email lists (the Righteous sort)

by George_Sherston (Vicar)
on Oct 18, 2002 at 15:30 UTC ( #206329=perlquestion: print w/replies, xml ) Need Help??
George_Sherston has asked for the wisdom of the Perl Monks concerning the following question:

Before I get Chipped let me assure you this is a pro bono project for a web-community site used by aid workers in the field, and the list in question is active opt-ins to this and only this non-profit service...

That said - my task is to automate the process of sending the weekly email, which at present is done by the administrator cutting and pasting fifty email addresses at a time into his email client's cc field. It's a simple job, as the emails are all on a MySQL db. BUT I've only ever done one-off emailings from scripts,a and I seem to remember hearing that Mail::Sendmail, my module of choice for these, can break at high volume. I looked at Mail::Bulkmail, which seems to do what I want, but hasn't had an update for a couple of years, which always makes me wary - is there some reason why it has languished? None of the other mail modules sounded like they did what I want, which is basically to do what Mail::Sendmail does, only reliably for large numbers. This sounds like something I'm only about the millionth person to want to do - do you have a fave module? Or am I wrong to fear Mail::Sendmail will break?

George Sherston

Replies are listed 'Best First'.
Re: Email lists (the Righteous sort)
by derby (Abbot) on Oct 18, 2002 at 16:59 UTC

    You didn't say what the total number of emails being sent are. If it's small (in the hundreds), I would look at wrapping Mail::Mailer and a tuned sendmail configuration; however, if it's in the thousands, Mail::Bulkmail may be fine. Mail::Bulkmail hasn't been updated in a while but I just looked at the code last month and except for a few colorful comments by the author, it was still quite solid.

    You may also want to look into some of the mailing list managers out there.


      At present the list is just short of 500, but new signups come in about ten a day, so realistically it's going to have to cope with thousands rather than hundreds. I'm reassured that you think Mail::Bulkmail is sound. I wonder why nobody's maintaining, given that it meets such an obvious need.

      George Sherston
        I've just recently used Mail::SendMail to send out 600 invitations and reminders for a graduate research survey. It took all of about 5 minutes or so. I've had no problems with it yet. I'd be interested in knowing what the magical cutoff point is--just in case I have to help someone with a larger mailout.


Re: Email lists (the Righteous sort)
by perrin (Chancellor) on Oct 18, 2002 at 17:54 UTC
    I've used Mail::Bulkmail. I found it a little bit tricky and wasn't impressed with the error handling. If I were doing a mailing list for an empoyer, I would write it so that it could be paused and could resume after errors part way through the list. However, Mail::Bulkmail can go very fast if you need to send the same message to many people and are willing to spend a little time getting it to work.

    If you don't want to mess with Mail::Bulkmail, the fastest option by far is to use qmail with the qmail-inject program. I know companies that use this to do their mail with great results. You can find wrappers around qmail-inject at Mail::Transport::Qmail and Mail::Mailer.

Re: Email lists (the Righteous sort)
by l2kashe (Deacon) on Oct 18, 2002 at 20:35 UTC
    I ran into something similar. My company has a few million customers, and we needed to send out mailings to all, or a portion of the client base, on a semi frequent basis.

    I rolled my own solution, as opposed to using a module (Bad me!), but the appropriate answer is multiple rcpt to statements. Then if you want to you can craft your CC header, with all the addresses, or not (which on an aside is exactly how Bcc works, rcpt to recipient with no entry in cc header :)

    Off the cuff code to illustrate the point, assuming that if $CC is defined, we will append the addresses, else they are Bcc'd
    @users = &Get_Users_from_Db("$some_db"); while ( defined($usr = shift(@users)) ) { chomp($usr); # # Assume the rcpt and send methods appropriatly process the # reponse from the server also here we would add error # checking for properly formated email addie. # $smtp->rcpt("$usr"); $cc_head ? $cc_head .= ", $usr" : $cc_head = "$usr"; } print $smtp->send("DATA"); # # At this point we talk directly to the socket because the # smtp server does not repond with anything till we are done # $socket = $smtp->socket(); print $socket "From: $from\n"; print $socket "To: $list_name\n"; print $socket "CC: $cc_head\n" if ($CC && $cc_head); print $socket "Subject: $subject\n\n"; print $socket "@message_body\n\n"; $ok = $smtp->send('.'); &Some_Error_Routine("sending mail") if (!$ok);
    Its just a basic rundown, but it shows the point. Also Ive had great results using Perl, and like I said I send emails in the millions, so 500 is a breeze. Also again I do not know the particulars of the modules implementation, but assume it was written by a far wiser man than I. It should support the rcpt or rcpt_to or something similar. Just make sure that if you are trying to Bcc the list that the module isnt going to append that info to the headers of the data section.

    Happy hacking, and on a quasi OT comment 'death to spammers'.. ;)

    /* And the Creator, against his better judgement, wrote man.c */
Re: Email lists (the Righteous sort)
by Mr. Muskrat (Canon) on Oct 18, 2002 at 15:43 UTC

    I send out anywhere from 3 to 6 automated emails every Friday afternoon to a list of around 35 people using Mail::Sendmail. It's very slow but so far it's never failed. I'm more concerned with the receiving server bouncing the message because the pager it's going to can only handle so many characters.

    At least you can pull the addresses from a MySQL database... I have to parse an Excel spreadsheet to get mine. That might actually be why it's so slow. ;)

    I think I'll look at Mail::Bulkmail. Who knows, maybe it's exactly what I need.

Re: Email lists (the Righteous sort)
by Aristotle (Chancellor) on Oct 18, 2002 at 20:49 UTC
    I (re)wrote a script for that at Re: Yet another tool for sending out newsletters. You might even want to use it verbatim and just write a script to pull the email addresses out of the database before sending for minimum effort.

    Makeshifts last the longest.

Re: Email lists (the Righteous sort)
by nothingmuch (Priest) on Oct 18, 2002 at 15:45 UTC
    I am not farmiliar with any. However conceptually i think this may be of aid - RCPT TO commands to SMTP are not included in headers. Should you use multiple RCPT TO commands per message you are not compromising your users' privacy (behavior is like BCC). Unless it's important to you to have a personalized To header i think your wisest choice would be to just mail it like that.

    Several months ago when i had fun reinventing wheels all the time I wrote a no-module thing to do that. It worked pretty well for a little (50 subscribers) list I had going. The fun is that you leave the hard work for your sendmail...

    zz zZ Z Z #!perl

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://206329]
Approved by rob_au
[Your Mother]: I prefer palatial fricatives.
[Lotus1]: https://en. wiki/%C3%87
[Your Mother]: I'm headed out west, sucker.
[Lotus1]: the west is the best, get here we'll do the rest
LanX chjuman !
[Eily]: do you pronunce that /xju:mən/ then ?
[Eily]: that's not what I'd call a silent h :)
[LanX]: see soundfile https://en. wiki/human# Pronunciation
[Your Mother]: Just Another Perl 'Acker.
[LanX]: I pronounce it 'juːmən'

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (15)
As of 2017-03-27 17:06 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (320 votes). Check out past polls.