Hi all,
I have 2 scripts that are sending email out through sendmail, one of them sends the mail 2X
I may be wrong here, but since I have one script that works fine, I am assuming that the problem has to be in the script itself, but being a novice with PERL, I cannot seem to find anything. If anyone can take a look at the code below and point me in the right direction or spot the problem, it would be a great help.
Thanks in advance,
Jim
I have 2 scripts that are sending email out through sendmail, one of them sends the mail 2X
I may be wrong here, but since I have one script that works fine, I am assuming that the problem has to be in the script itself, but being a novice with PERL, I cannot seem to find anything. If anyone can take a look at the code below and point me in the right direction or spot the problem, it would be a great help.
Thanks in advance,
Jim
Code:
#===== Send the card =====
sub send_card {
srand (time|$$);
$userid = int (rand(1000));
$userid .= "$$";
open (PAGE, "$thank_you") || die ("I am sorry, but I was unable to open the file $thank_you.");
while (<PAGE>) {
s/%%name%%/$input{'name'}/g;
s/%%pickup%%/$pickup/g;
print $_; }
close (PAGE);
open (DATABASE, ">>$cardlist") || die ("I am sorry, but I was unable to open the file.");
#===== Remove any pipe symbols from input =====
$input{'sender'} =~ s/\|//g;
$input{'message'} =~ s/\|//g;
$input{'name'} =~ s/\|//g;
$input{'senderemail'} =~ s/\|//g;
$input{'message'} =~ s/\s+/ /g;
flock (DATABASE, 2);
print DATABASE "$userid\|$input{'sender'}\|$input{'senderemail'}\|$input{'message'}\|";
print DATABASE "$input{'name'}\|$input{'card_number'}\|$time\|$date\n";
flock (DATABASE, 8);
close (DATABASE);
#===== Send e-mail to recipient =====
open (MAIL, "|$mailprog $input{'address'}") || die "Can't open $mailprog!\n";
print MAIL "Reply-to: $input{'senderemail'}\n";
print MAIL "From: $input{'senderemail'}\n";
print MAIL "To: $input{'address'}\n";
print MAIL "Subject: $subject\n\n";
open (PAGE, "$mail_message") || die ("I am sorry, but I was unable to open the file $thank_you.");
while (<PAGE>) {
s/%%sender%%/$input{'sender'}/g;
s/%%userid%%/$userid/g;
s/%%pickup%%/$pickup/g;
s/%%company%%/$company/g;
print MAIL $_;
}
close (PAGE);
close (MAIL);
}