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 bkrike 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 (works)
2) In the event that they are not, to recreate the form (works)
3) In the event that they are, to do the following:
a) To redirect the viewer to a confirmation screen (works)
b) To send the viewer an email, based on an if/then test, including the data from the form fields (does not work)
c) To send a third party an email containing the data from the form fields (does not work)

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 any errors in my code that I missed (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
}

#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 would make a small script that sends a email and test that it is working.

I cant get a error from your code
 
silly assumption you are running on a *nix box yes? and it's the same box as you tested on yesterday, and no-one modified its configuration?
Code:
require "cgi-lib.pl";
&ReadParse;

comment these lines out to test, and just assign the values you need
Code:
my %in;
$in{'email')="my\@myserver.com";
$in{'mmail'}="you\@yourserver.com";
...

the vars you're passing to ReadParse shouldn't need escaping, just when assign like this

Let us know how you get on
--Paul



It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ... smack the fecker
 
arcnon and Paul:

Thanks for checking out my script for me. I received an email from my hosting company this morning stating the following load of rubbish:

"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."

Looks like I'm shopping. Any recommendations?

Thanks again,
Meghan
 
What budget have you?, a decent linux box on cable might do the trick, might be a bit of chore to set up though ...

--Paul

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ... smack the fecker
 
One of my goals is my own Linux box, but that's still in the future (hopefully within the year). As is glaringly obvious by the gaps in my knowledge, I am (recently) self-taught, and haven't gotten around to the server side of things yet, so I'm still dependent on outside hosting. I have a voracious appetite for knowledge, though, and especially for anything that could ultimately prove profitable. Any suggestions on where I should start?

Meghan
 
The boards here are a good place to start asking questions about where to start

There used to a be a very good donations funded Linux learning course, complete with homework and all

I started it, but its run on a timetable, and my Dual boot machine got busted, so i couldn't turn in my homework

A "dummies" or "idiots" guide would probably be the best place to start to get the glossary right, before going to boards etc

HTH
--Paul


It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ... smack the fecker
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top