homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

Help With Form To Mail Script
complete Beginner

5+ Year Member

Msg#: 3351472 posted 10:26 pm on May 27, 2007 (gmt 0)

Hi! I was hoping someone could tell me what I've done wrong with the following script that has come from my webserver help files. It is a simple "form to e-mail" that I have to use on my Windows Server that doesn't support ASP, just PHP (Pearl?).
The script takes a comment and passes it to the right e-mail address, which is great, but I don't know how to get it to then direct the user to my thankyou page.
I am a complete novice at this and don't really understand what I'm doing, it's taken me three hours to get to the stage where I'm getting the e-mails I want.... I'm probably just missing something really simple. Many thanks in advance!
The script:

use OLE;
use CGI;
$jmail = CreateObject OLE "JMail.SMTPMail";
$form = new CGI;
$domain = $ENV {'SERVER_NAME'};
$referer = $ENV {'HTTP_REFERER'};
$url = $referer;
$url =~ s/^http:\/\///i;
$url =~ s/^www\.//i;
$domain =~ s/^www\.//i;
$Sender = "noreply\@$domain";
$SMTPServer = "smtp.$domain:25";
$Header = "Originating-IP",
$jmail->{ServerAddress} = $SMTPServer;
$jmail->{Sender} = $Sender;
$jmail->{Subject} = $Subject;
$jmail->AddRecipient ($Recipient);
$jmail->{Body} = $Body;
$jmail->{Priority} = $Priority;
$jmail->AddHeader ($Header);
if ($url =~ m/^$domain/)
$mailmessage = "mail sent";
$mailmessage = "mail was not sent.
Incorrect Referer";
print "Result: $mailmessage Recipient: $Recipient";
print "Sender: $Sender SMTP Server:
print "Subject: $Subject Referer: $referer";
print "Domain: $domain url: $url ";



WebmasterWorld Senior Member 10+ Year Member

Msg#: 3351472 posted 8:27 pm on May 29, 2007 (gmt 0)

(Resisting the urge to point out potential exploits in script)


This will send the user to your thank you page provide you have not already "printed" anything else to the browser:

$thanks = 'http://'.'YourDomain.com/YourThanks.Page'."\n\n";
print "Location: $thanks\n\n";

[Edit]Changed variable so that WW parser wouldn't try to hyperlink the URL, the $thanks var does not actually need all the concatenation[/Edit]

[edited by: IanKelley at 8:33 pm (utc) on May 29, 2007]


5+ Year Member

Msg#: 3351472 posted 8:28 pm on May 30, 2007 (gmt 0)

Many Thanks Ian!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved