Hello!

I am trying to code a script for subscription, but I need some help. Just like a program that is an online vacation reply manager with certain exception. In other words, when someone sends an email to the auto-responder, a follow-up begins depending on the content of the header.

My script will be located in cgi-bin directory on my site. The function of the script will be to check the content of header of incoming email. If subject of the incoming-email contains the words ďultimate brochure Ē (case insensitive), the script sends a one-time follow-up email to the subscriber with message in ďbrochure.txtĒ. Let us assume that the sender/subscriber of an email to me put a heading like ďI will like to subscribe for ultimate brochureĒ, the cgi-script must be able to scan the heading to see whether ďultimateĒ and ďbrochureĒ are among the words in the heading. Follow-up email is not sent if both ďultimateĒ and ďbrochureĒ words are not within the content of the heading.

My initial code is as below. It will be highly appreciated if somebody can put me through (in the form of coding) in this my endeavour. I thank you very much in advance for your help and enlightenment. hans.adamsson(at)wippies(dot)fi

Best regards,
Hans Adamsson, Finland


NB:

Script file: request.cgi
------------------------

#!/usr/bin/perl

################################
$script_name = 'request.cgi';
$from = 'info@mywebsite.net';
################################
# Path to Sendmail on my server.
$mailprog = '/usr/sbin/sendmail';
##################################
# Advanced Settings Auto Responder
$auto_responder_from = 'info@mywebsite.net';
$auto_responder_message = "brochure.txt";
##################################
# Subscribe Condition: Subject of email MUST contain the following words: ultimate brochure (case insensitive).
$subscribe_subject = "ultimate brochure";


#################################
# MAIN CODING FOR THE SCRIPT! #
#################################

use CGI qw/:standard :cgi-lib/;

@date=localtime();
$date[4]++;
$date[5]+=1900;
$date="$date[5]-$date[4]-$date[3]";

$scount = 0;
$uscount = 0;
$dcount = 0;
%messages = ();
$messages = $pop->list;
foreach $msgid (keys %$messages) {
$mymessage = $pop->get($msgid);
$to = "";
$from = "";
$subject = "";
if($mymessage) {
@mess = @$mymessage;
foreach $line (@mess) {
if ($line =~ m/To: /) {
$line =~ s/To: // unless ($line =~ m/Reply-To:/i);
$line =~ s/<//gm;
$line =~ s/>//gm;
chomp($line);
$to = $line;
}
if ($line =~ m/From: /) {
$line =~ s/From: //;
$line =~ s/<//gm;
$line =~ s/>//gm;
chomp($line);
@lines = split(/ /,$line);
foreach $line2(@lines) {
if($line2 =~ /\@/) { $from = $line2; }
}
}
if($line =~ m/Subject: /) {
$line =~ s/Subject: //;
chomp($line);
$subject = $line;
}
} #done message scan
$mfound = 0;
$to =~ tr/A-Z/a-z/;
$from =~ tr/A-Z/a-z/;
if($to eq $subscribe_email) { &subscribe; }
}
}



sub error
{
my $error = shift;
print <<EOF;
<title>Error</title>
Error: $error
EOF
exit;
}