For the past two years I have been sending out our monthly newsletter to our customers using the following code -- I've wanted to post here for a while and ask: Is there a way to send out an email to a few thousand people (4000) in ONE step? It is very important that BCC is used (for obvious reasons). Also, when I use the code below, it takes over an hour for the emails to get sent. During this period when someone visits our site, a visitor will occasionally get an internal server error which I'm think is related somehow to the mail/sendmail program.
Basically, I just want to know a quicker way to send out an email to a lot of people using BCC that sendmail can handle and that won't create errors. Just a note, this is not a spam email - these are emails we've accumulated over the past four years.
Thanks in advance!
---------------------------------------------------------
#!/usr/local/bin/perl
require "Lite.pm";
$address = "hgy.emllst"; # file with email addresses
$email_template = "email-sept-20-06.html"; # the 'email' in html form
+at (looks pretty)
$subject = "News for September 2006";
open(E,$email_template);
@F = <E>;
close(E);
$filehtml = join("",@F);
## open up the file with the email addresses
open(A,$address) || die "could not open $address for reading\n";
## read in the email addresses into the address array
@addresses = <A>;
## for each address in the list
for ($i=0; $i < @addresses; $i++)
{
if ($addresses[$i] ne "")
{
## send the customer an email
my $msg = MIME::Lite->new(
From =>'news@xxxxxxxx.com',
To =>"$addresses[$i]",
Subject =>"$subject",
Type =>'text/html',
Data =>"$filehtml");
$msg->send();
}
}
20060927 Janitored by Corion: Changed PRE to code tags, as per Writeup Formatting Tips
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.