History always repeats itself and sometimes that's good. Here's a second chance to be part of it: tmdtc.com

Friday 21 December 2007

bulkmail.pl to ease the sending of season's greetings

So I wanted to mail season's greetings to quite some people. And I needed a solution with very simple requirements:
  • recipients to be stored in a text file
  • message to be stored in a text file
  • To: set to the recipient's mail
With these requirements I couldn't use the solution based on ActiveMailer I used for MyOwnDB.
But I didn't find a solution. My currently prefered language being Ruby, I looked for a Ruby library, and found Bulkmail, but it didn't work out of the box, and error logs were not very informational. And I really didn't want to loose time on that....

As the title implies, I finally settled on using Perl's Mail::Bulkmail to write a small script with this usage:

bulkmail.pl -f '"mailer name" ' \
-m path/to/message.txt \
-r "/path/to/recipients_list.txt" \
-s "subject of mail"


You can put all the recipients in one text file, one recipient per line:
"John Doe"

You can download the script, but before running it, edit the config file to set the correct domain used for the SMTP HELO!

It had been years I haven't touched to Perl, and this wasn't enough to remind me of Perl's syntax and concepts. But this has only confirmed what I knew: Perl has an unbelievably high number of libraries and that can make it the tool to use for a lot of applications! Wondering if I shouldn't refresh my Perl :-)

No comments: