Current location: Hot Scripts Forums » Programming Languages » Perl » Autoresponder with header’s content sensitivity


Autoresponder with header’s content sensitivity

Reply
  #1 (permalink)  
Old 12-29-09, 03:57 AM
hansadamsson70 hansadamsson70 is offline
Newbie Coder
 
Join Date: Sep 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Rolleyes Autoresponder with header’s content sensitivity

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 Andersson, Finland


NB:

Script file: request.cgi
------------------------
Code:
#!/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;
}

Last edited by wirehopper; 12-29-09 at 09:31 AM. Reason: Code tags
Reply With Quote
Reply

Bookmarks

Tags
autoresponder, content, header, sensitive, sensitivity


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
make element follow page scroll ?! how-to k-knudsen JavaScript 12 08-04-09 02:03 PM
Make a div follow page scroll - the continued k-knudsen JavaScript 7 07-25-09 03:38 AM
Problem with layout bertrand HTML/XHTML/XML 4 11-08-07 07:30 AM
Error On Registeration timmy408 ASP 2 09-05-04 02:53 PM


All times are GMT -5. The time now is 04:53 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.