|
| Register now to interact with over 11,000 members! Registered users have Posting Privileges, free access to Private Messaging, Email Notifications and more. |
|
|||||||
![]() |
|
|
Thread Tools |
|
|
#1 |
|
Guest
Posts: n/a
|
Why is this simple script not working?
I'm getting the HTTP header message when I try to run the below script. I added some script the 2nd paragraph up from the bottom and I'm sure that is where the problem is. Can you see what I did wrong?
Thank you!!! ---------------------- #!/usr/bin/perl ################################################## ########### # # Script Source: CodeBrain.com # Source URL: http://www.codebrain.com/perl # Script Title: Alpha E-Mailer w/ Autoresponder # Script Name: AlphaMail.pl # Copyright: 1998,1999,2000 by OEC Corp & CodeBrain.com # Version: 09.01.1999.C (latest) # Status: Fully tested, release version 7, Y2K ready # # This script may not be redistributed without this header # # There are no restrictions on this script - anyone may use # it, though we appreciate credit where due. Responsibility # for use of the script is entirely with the user. Please # note that CodeBrain.com does not support Perl scripts! # # Instructions: # # - Use WordPad.exe or any plain text editor to edit # - Set your path to Perl as needed (first line at top) # - Set ALL variables appropriately (below, see notes) # - Take special care with the path to your sendmail (below) # - Send the script to the server in ascii # - Set script permissions - check your doc or ask admin # - See a_faq.html for HTML set-ups in alphamail.zip file # - Required html pages are also provided in alphamail.zip # ################################################## ########### ##### SETTABLE VARIABLES #################################### # URL to go to if there is a problem with form input $ErrorPage = "http://www.jdgraph.com/churchconstruction/error.html"; # URL to go to when form has been successfully submitted $ThankPage = "http://jdgraph.com/churchconstruction/thanks.html"; # URL to go to if a 'foreign' referer calls the script #$EvilReferer = "http://www.churchconstruction.com"; # E-mail address to send intake form to (your address) # If not using PERL 5, escape the @ thus: \@ instead of @ $YourEmail = 'jdutton@nwlink.com'; # Script works only on your server(s) - ('URL1','URL2') @referers = ('www.jdgraph.com','www.churchconstruction.com'); # Location of mail program - check your doc or ask admin $MailProgram = '/usr/lib/sendmail'; # Subject of the e-mail autoreply to the submitter $Subject = "Thank You for Your Submission"; # Header line in the auto-reply message #$Header = "GOOBERS UNLIMITED"; # Brief tail message for body of e-mail autoreply $TailMessage = "Thank you for contacting ChurchConstruction.com! We have received your feedback regarding a resource listed on our site. It is our priority to provide excellent construction and facility resources for the Christian community. To this end, we carefully review all references and vital information for each company listed. You have given us important information that will assist us with this goal. Thank you once again for taking the time to contact us. We wish you the best in all of your facility/construction endeavors. The Lord bless you."; # Your signature lines the end of the autoreply e-mail $Signature1 = "David B. Thacker"; $Signature2 = "Administrator"; $Signature3 = "http://www.ChurchConstruction.com"; ##### END OF SETTABLE VARIABLES ############################ ##### MAIN PROGRAM ######################################### # ___ Do not edit below this line __________________________ &CheckReferingURL; &ReadParse; $Name = $in{'Name'}; $Email = $in{'Email'}; $Message = $in{'Message'}; &CheckEmailAddressFormat; &CheckFields; &GetDate; &SendSubmission; &SendAutoReply; print "Location: $ThankPage\n\n"; exit; # __________________________________________________ _______ sub SendSubmission { open (MAIL,"|$MailProgram -t"); print MAIL "To: $YourEmail\n"; print MAIL "From: $Email\n"; print MAIL "Subject: $Subject\n"; print MAIL "$Date\n\n"; print MAIL "E-Mail Message\n\n"; print MAIL "From: $Name\n"; print MAIL "Email: $Email\n\n"; print MAIL "Message:\n\n"; print MAIL "$Message\n\n"; close (MAIL); } # __________________________________________________ _______ sub SendAutoReply { open (MAIL,"|$MailProgram -t"); print MAIL "To: $Email\n"; print MAIL "From: $YourEmail\n"; print MAIL "Subject: $Subject\n"; #print MAIL "$Header\n"; print MAIL "$Date\n\n"; #print MAIL "$Subject\n\n"; #print MAIL "You sent the following:\n\n"; #print MAIL "==============================\n\n"; #print MAIL "Name: $Name\n"; #print MAIL "Email: $Email\n\n"; #print MAIL "Message:\n\n"; #print MAIL "$Message\n\n"; #print MAIL "==============================\n\n"; print MAIL "$TailMessage\n\n"; print MAIL "Best regards,\n\n\n"; print MAIL "$Signature1\n"; print MAIL "$Signature2\n\n"; close (MAIL); } # __________________________________________________ _______ sub GetDate { @days = ('Sunday','Monday','Tuesday','Wednesday','Thursday ','Friday','Saturday'); @months = ('01','02','03','04','05','06','07','08','09','10' ,'11','12'); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isd st) = localtime(time); $year = $year+1900; $Date = "$days[$wday] $months[$mon]/$mday/$year"; } # __________________________________________________ _______ sub ReadParse { local (*in) = @_ if @_; local ($i, $key, $val); if ( $ENV{'REQUEST_METHOD'} eq "GET" ) {$in = $ENV{'QUERY_STRING'};} elsif ($ENV{'REQUEST_METHOD'} eq "POST") {read(STDIN,$in,$ENV{'CONTENT_LENGTH'});} else { $in = ( grep( !/^-/, @ARGV )) [0]; $in =~ s/\\&/&/g; } @in = split(/&/,$in); foreach $i (0 .. $#in) { $in[$i] =~ s/\+/ /g; ($key, $val) = split(/=/,$in[$i],2); $key =~ s/%(..)/pack("c",hex($1))/ge; $val =~ s/%(..)/pack("c",hex($1))/ge; $in{$key} .= "\0" if (defined($in{$key})); $in{$key} .= $val; } return length($in); } # __________________________________________________ _______ sub CheckEmailAddressFormat { if (index($Email, "@") < 1) {&DoEmailError;} if (index($Email, ".") < 1) {&DoEmailError;} if (index($Email, " ") > -1) {&DoEmailError;} my @required; if (!param('firstname')) { push(@required, 'First Name');} if (!param('lastname')) { push(@required, 'Last Name');} if (!param('phone')) { push(@required, 'Phone');} if (!param('Email')) { push(@required, 'Email');} if (!param('companyreporting')) { push(@required, 'Company You Are Reporting');} if (!param('companystate/province')) { push(@required, 'State/Province for Company You Are Reporting');} if (!param('comments')) { push(@required, 'Comments');} if (@required) { print header; print "You failed to fill in all of the required fields. Please go back and fill in the following fields:<br><hr>"; foreach (@required) { print "<b>$_</b><br>"; } exit; } # __________________________________________________ _______ sub CheckReferingURL { if ($ENV{'HTTP_REFERER'}) { foreach $referer (@referers) { if ($ENV{'HTTP_REFERER'} =~ /$referer/i) { $check_referer = '1'; last; }}} else {$check_referer = '1';} if ($check_referer != 1) { print "Location: $EvilReferer\n\n"; exit; }} # __________________________________________________ _______ exit; ##### End of Script ######################################## |
|
|
#2 |
|
Rick
Join Date: May 2002
Location: Minneapolis, MN
Posts: 1,695
Reputation: 280
|
Hi Sally,
$MailProgram = '/usr/lib/sendmail'; should be: $MailProgram = '/usr/sbin/sendmail'; That may not be the only problem, but its enough to cause a fault. Good luck!
__________________
Rick Trethewey |
|
|
|
|
#3 |
|
Guest
Posts: n/a
|
I fixed the mail line and it is still giving me the http header error message. I''ve uploaded it in ascii mode and have the permissions set at chmod 755 for the cgi script. Do I need to set those permissions for the html page also?
|
|
|
#4 |
|
Rick
Join Date: May 2002
Location: Minneapolis, MN
Posts: 1,695
Reputation: 280
|
Despite the docs, I think you need to escape the "@" sign in your EMail...
Change: $YourEmail = 'jdutton@nwlink.com'; to: $YourEmail = 'jdutton\@nwlink.com'; Good luck!
__________________
Rick Trethewey |
|
|
|
|
#5 |
|
Guest
Posts: n/a
|
Thank you! I changed the e-mail address to jdutton\@nwlink.com. Regretfully, I'm still getting the HTTP Header error message. Do I have the right number of }'s and ;'s in the 2nd paragraph from the bottom? I'm too new to CGI/Perl scripting to be able to tell.
|
|
|
#6 |
|
Guest
Posts: n/a
|
Hello...
This is a wild stab here... but are you uploading the script as ASCII and also making sure it has been CHMOD so that it can execute? ![]() |
|
|
#7 |
|
Guest
Posts: n/a
|
Yes the script file was uploaded with ascii and its permissions are set at chmod 755.
|
|
|
#8 |
|
Join Date: Feb 2002
Location: In My House
Posts: 2,134
Reputation: 70
|
you may have a problem in your $TailMessage.. the line feeds in there could be confusing things.. maybe try replacing w/ "\n\n" when you need a new paragraph and leave the whole message without line feeds?
that's all that's jumping out at me that hasn't been already pointed out.
__________________
~The WebWench~ Semi-Stix Studio (Free Music & Scripts!) - Crafters-Index (free patterns) - Neuadd Sibly (more free music) ______________________________________ Do not meddle in the affairs of dragons, for you are crunchy, and taste good with ketchup |
|
|
|
|
#9 |
|
Guest
Posts: n/a
|
I took out the line feeds and still got the HTTP Header error message. So I added a "}" after the "sub CheckEmailAddressFormat" paragraph and then tried it. I didn't get the HTTP Header message anymore. Instead I got a blank page that said:
--------- Found The document has moved here. --------------- The word "here" was underlined like a link, but when I clicked on it, it doesn't take me anywhere. Help! P.S. The "my@required" paragraph is what I added to the original script. |
|
|
#10 |
|
Guest
Posts: n/a
|
I think I figured out what is wrong. This script requires a certain form to be used (which I am not using). I'm going to try to find another script that will work better for me.
Thanks for all your help!! |
|
|
#11 |
|
Guest
Posts: n/a
|
I was looking for an email autoresponder for you and found one for free at: http://www.acjavascripts.com/CGIScriptsACMailer2.html
I have'nt tried it yet.I'm going to upload it and check it out. |
![]() |
| Thread Tools | |
|
|