Sindbad~EG File Manager

Current Path : /usr/home/beeson/Promotions/March2007/
Upload File :
Current File : /usr/home/beeson/Promotions/March2007/SendToMailingList.prl

# Perl script to send mail to a mailing list.
# the command line should contain two filenames.  The 
# first should be a text file containing one email address per line.
# The second should contain the message body to be sent (line breaks between paragraphs only, HTML OK).
# The script should send the message to every email address in the first file.

$replyTo = "Reply_to: sales@HelpWithMath.com\n";
$subject = "Subject: MathXpert half-price offer\n";
$contentType = "Content-type: text/html\n\n";
$sendmail = "/usr/sbin/sendmail -t";

$nargs = @ARGV;   # number of command line arguments
if($nargs != 2)
   { die ("Usage: SendToMailingList MailingList MessageBody\n");
   }

open(MAILINGLIST,$ARGV[0]) or die "Cannot open $ARGV[0]";
open(CONTENT, $ARGV[1]) or die "Cannot open $ARGV[1]";
while(<CONTENT>)
   { push(@content, $_);
   }
close(CONTENT);
   
$count = 0;
while(<MAILINGLIST>)
{ 
open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";    # opens a pipe to sendmail
print SENDMAIL $replyTo; 
print SENDMAIL $subject; 
print SENDMAIL "To: $_";
print SENDMAIL $ContentType;
foreach $line (@content)
   { print SENDMAIL $line;
   }
# now issue a line with only a period, to make sendmail send the message.
print SENDMAIL ".\n";
++$count;
# print "Sent mail to $_\n";
close(SENDMAIL);
print("$count\n")
}
print "Sent $count emails altogether.\n";
close(MAILINGLIST);



Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists