The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Autoresponder with header’s sensitivity
Hans
post Dec 29 2009, 01:29 PM
Post #1





Group: Members
Posts: 7
Joined: 14-September 09
Member No.: 9,750




Hi,

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;
}
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Hans
post Dec 30 2009, 07:40 AM
Post #2





Group: Members
Posts: 7
Joined: 14-September 09
Member No.: 9,750



Hi,

I just resend this message in order to preserve the code. I sorry for the repetition.

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


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;
}
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Dec 31 2009, 12:32 AM
Post #3


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



QUOTE
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.


Do you really mean "an incoming email"?? Isn't this script for handling an html form ?

(I really don't know -- I don't speak perl, and it is not obvious from the comments at the top of the script. Where did it come from? If you find someone who happens to be familiar with this particular script, they can perhaps help immediately. Otherwise working out what it is doing is hard work, not likely to be done unpaid...)

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Hans
post Jan 1 2010, 07:11 AM
Post #4





Group: Members
Posts: 7
Joined: 14-September 09
Member No.: 9,750



Hello,

I am trying to code a script for subscription, but I need some help.

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.fi

Best regards,
Hans Adamsson, 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;
}



User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Hans
post Jan 1 2010, 07:15 AM
Post #5





Group: Members
Posts: 7
Joined: 14-September 09
Member No.: 9,750



Hi Brian Chandler,

I mean an incoming e-mail.

Best regards,
Hans
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th April 2024 - 03:45 AM