in reply to Sending mail using perl

Someone here at the Monastery got me onto Mime::Lite which I like over Mail::Sendmail which I was using. Mime::Lite makes adding attachments so much easier.

use MIME::Lite; for (@email_recipients) { #-- create the multipart container my $msg = MIME::Lite->new ( From => $query->param('fromwho'), To => $_, Subject => $query->param('subject'), Type =>'multipart/mixed' ) or die "Error creating multipart container: $!\n"; #-- add the text message part $msg->attach ( Type => 'TEXT', Data => $query->param('message'), ) or die "Error adding the text message part: $!\n"; #-- add the ZIP file $msg->attach ( Type => 'AUTO', Path => "../".$file, Filename => $file, Disposition => 'attachment' ) or die "Error adding $file: $!\n"; $msg->send; sleep(1); }

Note the use of the delay at the end of the loop. This avoids the batch e-mail appearance to some spam filters. However, it may be moot because many ISPs limit the number of emails you can send at once or in an hour.


—Brad
"The important work of moving the world forward does not wait to be done by perfect men." George Eliot