crazy8
10-04-2007, 10:30 AM
Ok I have never done any CGI stuff at all so this is totaly new to me. My boss is wondering if there is a way to have the script kill emails that contain certain key words? The case now, he would like all emails with the word "Goodsite" in the message to be killed/deleted. Is there a way to do this either directly in the CGI script or PHP or anything? Thanks for the help. Here is what the CGI script looks like. At least im sure this is whats needed.
#!/usr/bin/perl
##############################################################################
# Cliff's Form Mailer Version 1.0 #
# Copyright 1998 Shaven Ferret Productions #
# Created 6/4/98 #
# Available at http://www.shavenferret.com/scripts #
##############################################################################
# COPYRIGHT NOTICE #
# Copyright 1998 Shaven Ferret Productions All Rights Reserved. #
# #
# This script can be used\modified free of charge as long as you don't #
# change this header thing, or the part that gives me credit for writing #
# script in the e-mail. If you really need to remove this part, go to #
# http://www.shavenferret.com/scripts/register.shtml . By using this script #
# you agree to indemnifyme from any liability that might arise from its use. #
# In simple English, if this script somehow makes your computer run amuck #
# and kill the pope, it's not my fault. #
# #
# Redistributing\selling the code for this program without prior written #
# consent is expressly forbidden. #
##############################################################################
# Enter the location of sendmail.
$mailprogram = "/usr/lib/sendmail -t";
# Enter the fields that are required. They should each be in quotes and
# separated by a comma. If no fields are required, change the next line
# to @required = ();
@required = ('email','subject');
# Enter your e-mail address. Be sure to put a \ in front of the @.
# (user@domain.com becomes user\@domain.com)
$youremail = "gkmundt\@mindspring.com";
##############################################################################
# Congratulations! You've finished defining the variables. If you want to, #
# you can continue screwing with the script, but it isn't necessary. #
##############################################################################
# Put the posted data into variables
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
# Check for all required fields
foreach $check(@required) {
unless ($FORM{$check}) {
print "Content-type: text/html\n\n";
print "<html><head><title>Missing Information</title></head>\n";
print "<body><h1>Missing Information</h1><br>\n";
print "I'm sorry, but it would appear that you've forgotten to\n";
print "fill out the $check field. Please click\n";
print "back and try again.\n";
print "</body></html>\n";
exit;
}
}
# Check the senders email
if ($FORM{'email'}) {
unless ($FORM{'email'} =~ /\w+@\w+.\w+/) {
print "Content-type: text/html\n\n";
print "<html><head><title>Bad E-mail</title></head>\n";
print "<body><h1>Bad E-mail</h1><br>The e-mail address that you've\n";
print "entered, $FORM{'email'}, is invalid. Please click back and\n";
print "try again.\n";
exit;
}
}
open (MAIL,"|$mailprogram");
print MAIL "To: $youremail\n";
print MAIL "From: $FORM{'email'}\n";
print MAIL "Subject: $FORM{'subject'}\n";
print MAIL "Hello. The following information has been submitted:\n\n";
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
unless ($name eq "response" || $name eq "email" || $name eq "subject") {
print MAIL "$name: $value\n";
}
}
close MAIL;
if ($FORM{'response'} && $FORM{'email'}) {
open (RESPONSE, $FORM{'response'});
@response = <RESPONSE>;
close(RESPONSE);
open (MAIL,"|$mailprogram");
print MAIL "To: $FORM{'email'}\n";
print MAIL "From: $youremail\n";
print MAIL "Subject: $FORM{'subject'} -- Autoresponse\n";
foreach $line (@response) {
print MAIL "$line";
}
print MAIL "The person you are communicating with is using Cliff's\n";
print MAIL "Form Mailer Script. If you would like to add this script\n";
print MAIL "to your web site, you can find it and many more perl scripts at\n";
print MAIL "http://www.shavenferret.com/scripts\n";
close MAIL;
}
print "Content-type: text/html\n\n";
print "<html><head><title>Thank you!</title></head>\n";
print "<body><h1>Thank you!</h1><br>Thanks for your input! \n";
if ($FORM{'response'} && $FORM{'email'}) {
print "You should receive an autoresponse shortly.<p>\n";
}
print "Please close window.\n";
Thanks alot for the help
#!/usr/bin/perl
##############################################################################
# Cliff's Form Mailer Version 1.0 #
# Copyright 1998 Shaven Ferret Productions #
# Created 6/4/98 #
# Available at http://www.shavenferret.com/scripts #
##############################################################################
# COPYRIGHT NOTICE #
# Copyright 1998 Shaven Ferret Productions All Rights Reserved. #
# #
# This script can be used\modified free of charge as long as you don't #
# change this header thing, or the part that gives me credit for writing #
# script in the e-mail. If you really need to remove this part, go to #
# http://www.shavenferret.com/scripts/register.shtml . By using this script #
# you agree to indemnifyme from any liability that might arise from its use. #
# In simple English, if this script somehow makes your computer run amuck #
# and kill the pope, it's not my fault. #
# #
# Redistributing\selling the code for this program without prior written #
# consent is expressly forbidden. #
##############################################################################
# Enter the location of sendmail.
$mailprogram = "/usr/lib/sendmail -t";
# Enter the fields that are required. They should each be in quotes and
# separated by a comma. If no fields are required, change the next line
# to @required = ();
@required = ('email','subject');
# Enter your e-mail address. Be sure to put a \ in front of the @.
# (user@domain.com becomes user\@domain.com)
$youremail = "gkmundt\@mindspring.com";
##############################################################################
# Congratulations! You've finished defining the variables. If you want to, #
# you can continue screwing with the script, but it isn't necessary. #
##############################################################################
# Put the posted data into variables
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
# Check for all required fields
foreach $check(@required) {
unless ($FORM{$check}) {
print "Content-type: text/html\n\n";
print "<html><head><title>Missing Information</title></head>\n";
print "<body><h1>Missing Information</h1><br>\n";
print "I'm sorry, but it would appear that you've forgotten to\n";
print "fill out the $check field. Please click\n";
print "back and try again.\n";
print "</body></html>\n";
exit;
}
}
# Check the senders email
if ($FORM{'email'}) {
unless ($FORM{'email'} =~ /\w+@\w+.\w+/) {
print "Content-type: text/html\n\n";
print "<html><head><title>Bad E-mail</title></head>\n";
print "<body><h1>Bad E-mail</h1><br>The e-mail address that you've\n";
print "entered, $FORM{'email'}, is invalid. Please click back and\n";
print "try again.\n";
exit;
}
}
open (MAIL,"|$mailprogram");
print MAIL "To: $youremail\n";
print MAIL "From: $FORM{'email'}\n";
print MAIL "Subject: $FORM{'subject'}\n";
print MAIL "Hello. The following information has been submitted:\n\n";
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
unless ($name eq "response" || $name eq "email" || $name eq "subject") {
print MAIL "$name: $value\n";
}
}
close MAIL;
if ($FORM{'response'} && $FORM{'email'}) {
open (RESPONSE, $FORM{'response'});
@response = <RESPONSE>;
close(RESPONSE);
open (MAIL,"|$mailprogram");
print MAIL "To: $FORM{'email'}\n";
print MAIL "From: $youremail\n";
print MAIL "Subject: $FORM{'subject'} -- Autoresponse\n";
foreach $line (@response) {
print MAIL "$line";
}
print MAIL "The person you are communicating with is using Cliff's\n";
print MAIL "Form Mailer Script. If you would like to add this script\n";
print MAIL "to your web site, you can find it and many more perl scripts at\n";
print MAIL "http://www.shavenferret.com/scripts\n";
close MAIL;
}
print "Content-type: text/html\n\n";
print "<html><head><title>Thank you!</title></head>\n";
print "<body><h1>Thank you!</h1><br>Thanks for your input! \n";
if ($FORM{'response'} && $FORM{'email'}) {
print "You should receive an autoresponse shortly.<p>\n";
}
print "Please close window.\n";
Thanks alot for the help