in reply to Bulk Mail

I did a really basic mailer, but I highly recommend Mail::Bulkmail, as it provides many, many more features and error checking etc.

If your are interested:

Mailer:

use strict; use warnings; use Mail::Sendmail; my $from = '"Company Surveys" <surveys@surveys.com>'; my $subject = 'Your Survey'; open LIST, "<mailinglist" or die "Cannot open mailing list: $!"; open MESSAGE, "<mailinglist-message" or die "Cannot open mailinglist message: $!"; my @message = <MESSAGE>; my %mails = ( From => "$from", Subject => "$subject", Message => join "", @message, ); while (<LIST>) { sendmail('To' => $_, %mails) or warn $Mail::Sendmail::error; print "Message has been sent to $_"; }; close LIST; close MESSAGE; print "All e-mails sent successfully.\n\n";

Update: while was a foreach, due to a bad coding mistake. Thanks Animator

mailinglist-message is something like:

Dear Potential Customer, blah blah From time to time, we would like to send you more surveys and our newsletter. We respect your privacy, therefore, if you wish to unsubscribe from our list, please reply, changing the Subject Line to: unsubscribe

mailinglist is something like:

ghenry@me.com ghenry@me.org gavin.henry@me.com ghenry@me.co.uk ghenry@me.uk
etc. etc.

HTH.

Walking the road to enlightenment... I found a penguin and a camel on the way.....
Fancy a yourname@perl.me.uk? Just ask!!!

Replies are listed 'Best First'.
Re^2: Bulk Mail
by Animator (Hermit) on May 04, 2005 at 11:04 UTC

    foreach (<LIST>) ==> this is a bad idea (and bad practice)...

    This is what happens if you use it: first a temporary list is created, and that list will be passed to foreach. This means you are first reading the entire file, it would be much better to read it line by line...

    (Which you can do by using something like while (<LIST>)...)

    (Update, typo)

      Yes of course. Thanks for the advice.

      I'll update it.

      Walking the road to enlightenment... I found a penguin and a camel on the way.....
      Fancy a yourname@perl.me.uk? Just ask!!!