Valkerri has asked for the wisdom of the Perl Monks concerning the following question:
The code below works (when used with real addresses etc.). It sends a weekly email newsletter out via a very simple HTML form. Right now I simply paste the email mailing list into the script. Eventually, it will talk to a MySQL database.
Honestly, I wasn't really expecting this to get very large. I greatly underestimated the popularity of my client. She is getting about 100 people signing up for her newsletter every week.
I am worried that this code is simply not robust enough for a large mailing list. For example, could it time out before delivering all the messages if the email list got too long?
Please let me know how I can improve this script as: (a) the mailing list grows, (b) I intergrate it with MySQL, and (c) I eventually turn the mailing of the newsletter over to office staff.
#!/usr/bin/perl -w use strict; use CGI qw(:standard); use CGI::Carp 'fatalsToBrowser'; my $request = new CGI; my @emaillist = ("name\@domain.com","anothername\@anotherdomain.com"); my $messagebody = ""; my @form_fields = $request -> param; my $thankyoupage = 'http://www.domain.com/Thanks.html'; my $field = ""; foreach $field (@form_fields) { my $value = $request -> param ($field); my $f = uc ($field); $messagebody .= $value . "\n\n"; } my $n = ""; foreach $n (@emaillist) { open(MAIL, "|/usr/sbin/sendmail -t") or die "Could not open Sendmail \ +n\n $!"; print MAIL "To: $n\n"; print MAIL "From: newsletter\@domain.com\n"; print MAIL "Subject: The Weekly Newsletter\n"; print MAIL "Content-type: text/plain\n\n"; print MAIL "$messagebody\n\n"; close(MAIL) or die "Could not close Sendmail \n\n $!"; } print "Location: $thankyoupage\n\n"; exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sendmail with large address book
by MZSanford (Curate) on Aug 28, 2001 at 17:21 UTC | |
|
Re: Sendmail with large address book
by arhuman (Vicar) on Aug 28, 2001 at 17:25 UTC | |
|
Re: Sendmail with large address book
by tachyon (Chancellor) on Aug 28, 2001 at 18:05 UTC |