quelance has asked for the wisdom of the Perl Monks concerning the following question:
PS: I'm not sure if this is possible but can you send an email that will display html in html compatible email readers and text otherwise? (if so how would I encorporate this into my example)use Net::SMTP; #use Mail::Bulkmail; #Couldn't get this working on my U server #use Mime::Lite; #Server didn't like this my $mail_from = 'me@server.ca';< my @mail_to = ('1@server.com','2@server.com',...); my $subject = 'My subject eh'; my $count = 0; my $index = 0; my $message = q( <b>Some html text</b> ); #SMTP aliases to be reused to lessen the server load by not keeping ma +ny ports open my $smtp1 = Net::SMTP->new('my.mailserver.ca'); my $smtp2 = Net::SMTP->new('my.mailserver.ca'); my $smtp3 = Net::SMTP->new('my.mailserver.ca'); my $smtp4 = Net::SMTP->new('my.mailserver.ca'); while($index<=$#mail_to) { $smtp1->mail($mail_from); $smtp1->recipient($mail_to[$index]); $smtp1->data(); $smtp1->datasend("To: $mail_to[$index]\n"); $smtp1-> datasend ("Subject: $subject\n"); $smtp1-> datasend ("Mime-Version: 1.0\;\n"); $smtp1-> datasend ("Content-Type: text/html; charset='ISO-8859-1';\n\n +"); $smtp1->datasend($message); $smtp1->dataend(); $index++; $smtp2->mail($mail_from); $smtp2->recipient($mail_to[$index]); $smtp2->data(); $smtp2->datasend("To: $mail_to[$index]\n"); $smtp2-> datasend ("Subject: $subject\n"); $smtp2-> datasend ("Mime-Version: 1.0\;\n"); $smtp2-> datasend ("Content-Type: text/html; charset='ISO-8859-1';\n\n +"); $smtp2->datasend($message); $smtp2->dataend(); $index++; $smtp3->mail($mail_from); $smtp3->recipient($mail_to[$index]); $smtp3->data(); $smtp3->datasend("To: $mail_to[$index]\n"); $smtp3-> datasend ("Subject: $subject\n"); $smtp3-> datasend ("Mime-Version: 1.0\;\n"); $smtp3-> datasend ("Content-Type: text/html; charset='ISO-8859-1';\n\n +"); $smtp3->datasend($message); $smtp3->dataend(); $index++; $smtp4->mail($mail_from); $smtp4->recipient($mail_to[$index]); $smtp4->data(); $smtp4->datasend("To: $mail_to[$index]\n"); $smtp4-> datasend ("Subject: $subject\n"); $smtp4-> datasend ("Mime-Version: 1.0\;\n"); $smtp4-> datasend ("Content-Type: text/html; charset='ISO-8859-1';\n\n +"); $smtp4->datasend($message); $smtp4->dataend(); $index++; $count += 4; if($count == 40) { sleep(60); $count = 0; } } $smtp1->quit; $smtp2->quit; $smtp3->quit; $smtp4->quit; print "Mail sent succesfully, I think :)";
Edited by Chady -- added code tags.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::SMTP - mass mail
by davido (Cardinal) on May 09, 2004 at 04:12 UTC | |
|
Re: Net::SMTP - mass mail
by chanio (Priest) on May 09, 2004 at 06:12 UTC | |
by ozone (Friar) on May 09, 2004 at 11:58 UTC | |
|
Re: Net::SMTP - mass mail
by saintbrie (Scribe) on May 09, 2004 at 13:24 UTC | |
|
Re: Net::SMTP - mass mail
by sacked (Hermit) on May 09, 2004 at 19:02 UTC |