Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sendmail worked, now won't

Status
Not open for further replies.

megp

Programmer
Aug 25, 2004
31
US
I need another set of eyes to look at this and see what I'm missing...

This CGI/Perl script has the following purposes:
1) To verify that the required form fields are completed
2) In the event that they are not, to recreate the form
3) In the event that they are, to do the following:
a) To redirect the viewer to a confirmation screen
b) To send the viewer an email, based on an if/then test, including the data from the form fields
c) To send a third party an email containing the data from the form fields

When I tested the program yesterday morning, the "pay by check" email was sent to the viewer, but the third party email was not sent. When I subsequently tested it, none of the email functions worked. I have verified with the host that the sendmail path is correct. Do you see anything in my code that I need to fix to make this work (I've taken out the section to verify the form fields and recreate the form, to save space)? Thank you in advance.

Code:
#!/usr/bin/perl

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

#Define variable identifying path to sendmail program
$mailprog = '/usr/lib/sendmail';

#Verify name, phone and email fields are not blank
#Recreate form and shut down program
#If all required info is present print confirmation message 

#If pay by check
if ($in{'payment'} eq "check")
{
#Open sendmail program to send message to pay by check
open (MAIL, "|$mailprog -t") || die "Can't open mail program\n";

#Print message headers (To, Reply-To, From, Subject)
print MAIL "To: $in{'email'}\n";
print MAIL "Reply-To: $in{'mmail'}\n";
print MAIL "From: $in{'mmail'}\n";
print MAIL "Subject: Thank you for your support\!\n\n";

#Print body of message
print MAIL <<"PrintTag";
Thank you for your RSVP to the Vineyard of Hope Wine Tasting and Silent Auction!

In order to keep our administrative costs low, we do not print individual tickets.  Please accept this letter as confirmation of your reservation.  Your name will be included on the guest list at the door.  Please print a copy of this letter and mail with your check to:

	Catholic Social Services
	Attn: Sherry Luc
	1123 South Church Street
	Charlotte, NC  28203

If you need to cancel, we ask that you do so at least three business days prior to the event in order to receive a refund.

Should you have any questions regarding the event, or should you need to change your registration information as it appears below, please contact Joyce Bonaventura at 704-376-8870, or by email at joyceb\@vineyardofhope.com. 

Your registration information is:

	Name:		$in{'name'}
	Address:	$in{'add1'}
			$in{'add2'}
			$in{'city_state_zip'}
	Phone:		$in{'daytime_phone'}
	Email Address:	$in{'email'}
	Couples:	$in{'couples'}
	Individuals:	$in{'individuals'}
	Total Cost:	\$ $in{'total'}

We look forward to seeing you and thank you for your support of Catholic Social Services!
PrintTag

#Close sendmail program, releasing message to be sent
close (MAIL);
}

#If pay by credit card
else
{
#Open sendmail program to send message
open (MAIL, "|$mailprog -t") || die "Can't open mail program\n";

#Print message headers (To, Reply-To, From, Subject)
print MAIL "To: $in{'email'}\n";
print MAIL "Reply-To: $in{'mmail'}\n";
print MAIL "From: $in{'mmail'}\n";
print MAIL "Subject: Thank you for your support\!\n\n";

#Print body of message
print MAIL <<"PrintTag";
Thank you for your RSVP to the Vineyard of Hope Wine Tasting and Silent Auction!

In order to keep our administrative costs low, we do not print individual tickets.  Please accept this letter as confirmation of your reservation.  Your name will be included on the guest list at the door.  We will contact you within 48 hours to obtain the necessary credit card information to confirm your reservation.

If you need to cancel, we ask that you do so at least three business days prior to the event in order to receive a refund.

Should you have any questions regarding the event, or should you need to change your registration information as it appears below, please contact Joyce Bonaventura at 704-376-8870, or by email at joyceb\@vineyardofhope.com. 

Your registration information is:

	Name:		$in{'name'}
	Address:	$in{'add1'}
			$in{'add2'}
			$in{'city_state_zip'}
	Phone:		$in{'daytime_phone'}
	Email Address:	$in{'email'}
	Couples:	$in{'couples'}
	Individuals:	$in{'individuals'}
	Total Cost:	\$ $in{'total'}

We look forward to seeing you and thank you for your support of Catholic Social Services!
PrintTag

#Close sendmail program, releasing message to be sent
close (MAIL);
}

#Open sendmail program to send message to Vineyard of Hope
open (MAIL, "|$mailprog -t") || die "Can't open mail program\n";

#Print message headers (To, Reply-To, From, Subject)
print MAIL "To: $in{'mmail'}\n";
print MAIL "Reply-To: $in{'email'}\n";
print MAIL "From: $in{'email'}\n";
print MAIL "Subject: VOH Reservation\n\n";

#Print body of message
print MAIL <<"PrintTag";
A reservation request has been submitted with the following information:

	Name:		$in{'name'}
	Address:	$in{'add1'}
			$in{'add2'}
			$in{'city_state_zip'}
	Phone:		$in{'daytime_phone'}
	Email Address:	$in{'email'}
	Couples:	$in{'couples'}
	Individuals:	$in{'individuals'}
	Total Cost:	\$ $in{'total'}
	Payment Type:	$in{'payment'}
PrintTag

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

#End of script
 
I don't know why your messages aren't appearing, but I do have a suggestion:

Don't include your email address as one of the form parameters (presumably it's there as an <input type="hidden">). Putting your address in the form makes it available for spammers to harvest. Instead, hard-code it into the script - put this near the top:
Code:
$mymail = "contact\@example.com";
and change any references to [tt]$in{'mmail'}[/tt] to say [tt]$mymail[/tt] instead.

-- Chris Hunt
 
Chris:

Thanks for the tip. I will most definitely put that into practice. As for why my messages aren't coming through, I got the following load of rubbish from my hosting company this morning:

"We have been experiencing a large volume of email that is flowing through our formmail server at this time. As a result, there is a large back load of mail that has been queued. NO email has been lost. We are currently working to relieve this backlog of mail, and are flushing out all pending mail. You should receive your mail shortly."

Unacceptable when the purpose of the site is the sendmail program. So, I'm now shopping for a new host. Any recommendations?

Thanks again,
Meghan
 
If what they say is true, it sounds like some spammer is using somebody's insecure formmail program to send piles of junk. That's why you should never include a "to" address in a form.

I can't really recommend any hosts. The one I use is tolerable, but their customer service is a bit haphazard. Do a search of this forum and you should find a few threads discussing hosting.

-- Chris Hunt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top