Autoresponse Form Program

K

Khnum

Hello, I am very new to Programming. I am even newer to programming
with CGI/Perl. I just recently finished a class teaching us the
beginner stuff. I thought I was doing well.

I used the Autoresponse Form Program that was given to us as a learning
tool. I edited it and used it on a practice site that I use to test new
programs. When I tried to transfer that same program to the website I
am developing for my office it just stopped working. My web host (who
is a very busy friend told me to check the code. I did that line by
line and ran it again, but to no avail. I receive no error messages.
The program runs and returns me to the thank you for submitting.....
page, but dosen't send out an email. It should send me and email and
send a response email to the person who filled out the form.

I know this is probably very basic for you guys, but can anyone help
me. I thnank you in advance.

I have include the code below:

#!/usr/local/bin/perl

#run subroutine to turn stdin into an array named %in
require "cgi-lib.pl";
&ReadParse;

#store location of mail program in variable
#your mail program's locale may differ
$mailprog = '/usr/sbin/sendmail';

#use cgi-lib.pl subroutine to set content type
print &PrintHeader;

unless (-e $mailprog)
{
print <<"PrintTag";
<HTML><BODY>
<H3>Cannot find $mailprog.</H3>
<P>There is a typo in the mail program path.</P>
</BODY></HTML>
PrintTag
exit(0);
}

#create confirmation web page
print <<"PrintTag";
<HTML><HEAD>
<TITLE>Thanks submitting your Sign request!</TITLE>
</HEAD>
<BODY BGCOLOR="white" TEXT="black">
<H2>Thank You! $in{'Name'}</H2>
<P>Your Sign request has been received.</P>
<P>We will be ordering your Sign immediately.</P>
<!-- change the URL below to YOUR home page -->
<a href="http://www.commercialcondominium.com">Home</a>
</body></html>
PrintTag

#open mail program
open (MAIL, "|$mailprog -t") ||
die "Can't open mail program\n";

#print message headers (to, from, subject, etc)
print MAIL "To: $in{'Email'}\n";
print MAIL "Reply-To: $in{'empmail'}\n";
print MAIL "From: $in{'empmail'}\n";
print MAIL "Subject: Your Sign request.\n\n";

#print body of message
print MAIL << "PrintTag";
Dear $in{'Name'}:

Thank you for your Sign order.

This e-mail confirms that we have received your Sign request.

We will be ordering your Sign immediately!

Sincerely yours,

Kevin Bailey
CCMC
PrintTag

#close mail program, releasing message to be sent
close(MAIL);

#open mail program for a second message to employee
open (MAIL, "|$mailprog -t") || die "Can't open mail program\n";

#print message headers
print MAIL "To: $in{'empmail'}\n";
print MAIL "Reply-To: $in{'Email'}\n";
print MAIL "From: $in{'Email'}\n";
print MAIL "Subject: Sign request.\n\n";

#create body of message
print MAIL << "PrintTag";
Please place Sign order for:

$in{'PropertyName'}
$in{'Name'}
$in{'BusinessName'}
$in{'Address'}
$in{'CityStateZip'}
$in{'BusinessPhone'}
$in{'BusinessFax'}
$in{'Email'}
$in{'Owner'}
$in{'Tenant'}

$in{'TextArea'}
PrintTag

#close mail program and send message
close(MAIL);

#end of program
 
G

Gunnar Hjalmarsson

Khnum said:
Hello, I am very new to Programming. I am even newer to programming
with CGI/Perl. I just recently finished a class teaching us the
beginner stuff. I thought I was doing well.

I used the Autoresponse Form Program that was given to us as a learning
tool.

Hmm.. Was that program given to you as a learning tool in a Perl class
2005? That's scaring, because the program is terrible.

- It opens up for spammers to send any crap to a list of victims.
- The coding style is about 10 years old.

In other words: Please don't try to use it. ;-)
I receive no error messages.

One reason may be that you don't ask for them...
#close mail program, releasing message to be sent
close(MAIL);

One thing to check for is the return value of close():

close MAIL or die $!;
#close mail program and send message
close(MAIL);

close MAIL or die $!;

That might catch the case that sendmail didn't send the message
successfully.

But, again: Please don't use the script. Check out one of the
form-to-mail scripts at http://nms-cgi.sourceforge.net/scripts.shtml
instead.
 
P

Paul Lalli

Khnum said:
Hello, I am very new to Programming. I am even newer to programming
with CGI/Perl. I just recently finished a class teaching us the
beginner stuff.

To be blunter than Gunnar was - can you please tell us what and where
this course was, so we know to avoid it at all costs?

Whoever taught it has no business teaching a course on Perl in this
millenium.

Thank you,
Paul Lalli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top