posted
I'm trying to get a system set up for the company website that will allow customers to enter a few details and request a service technician through the web. I'm using a CGI script and HTML form to collect and process data. I've gotten the script to return the data that is entered in the form and display it in the browser. Unfortunately, I can't seem to get the script to send an actual email. I don't even know if my syntax is correct for the sendmail system. I've got the sendmail directory right (I checked the server requirements a few times to make sure). I just don't know what I'm doing wrong here and most of the tutorials I've found are either too complex or not compatible with the server I'm using (They return syntax errors when I run them through the web server's perl analyzer, and they return Internal Server Errors when I try to run the scripts). Here's the script I'm running. Please help. I don't want my head to blow up. (Some brackets changed to protect the weak minded, AKA, the posting requirements)
quote: #!/usr/bin/perl
do "cgi-lib.pl";
&ReadParse(*input);
$compname= $input{'compname'}; $phone= $input{'phonenum'}; $contact= $input{'name'}; $street= $input{'street'}; $city= $input{'city'}; $problem= $input{'problem'}; $from= "abrown@jeffuswilliams.com"; $to= "abrown@jeffuswilliams.com"; $subject= "$compname has requested service from Jeffus & Williams";
open(MAIL, "|/usr/sbin/sendmail -t") or die "Cannot open /usr/sbin/sendmail -t: $!"; print MAIL "To: $to"; print MAIL "From: $from"; print MAIL "Subject: $subject\n\n"; print MAIL "Content-type: text/plain\n\n"; print MAIL "Company Name: $compname\n"; print MAIL "Phone: $phone\n"; print MAIL "Contact: $contact\n"; print MAIL "Address:\n $street\n $city\n"; print MAIL "Problem:\n $problem"; close(MAIL);
print "Content-type: text/html\n\n"; print "{HTML}{BODY}"; print "Thank you $name for your request.<br />"; print "A technician will contact you soon to get more details and schedule a time to serve you.<br />"; print "Your information is as follows:<br />"; print "Company: $compname<br />"; print "Contact: $contact<br />"; print "Address:<br />"; print "$street<br />"; print "$city<br />"; print "Problem:<br />"; print "$problem"; print "{/BODY}{/HTML}";
posted
I would have it write the commands that you are sending to MAIL to a file. Then look at the file and see if it's what you expected. Try running sendmail on that file and see what errors you get.
Posts: 159 | Registered: Jun 2006
| IP: Logged |
posted
I have no advice for you, Boris, but I did want to stop by and say "Hi! Haven't seen you for a while! Glad to see you here! What'cha been up to?"
Posts: 8355 | Registered: Apr 2003
| IP: Logged |
posted
If you put "use strict;" at the top you will get a clear error if something like that happens again.
Posts: 159 | Registered: Jun 2006
| IP: Logged |
quote:Originally posted by Chanie: If you put "use strict;" at the top you will get a clear error if something like that happens again.
Well, since I'm doing everything from a webserver and not through anything local, I don't know if that works. I'll give it a try, though.
Posts: 3003 | Registered: Oct 2004
| IP: Logged |
quote:Originally posted by quidscribis: I have no advice for you, Boris, but I did want to stop by and say "Hi! Haven't seen you for a while! Glad to see you here! What'cha been up to?"
Not a whole lot. Just been working lately. Settling in to life in Alaska pretty well. I lost my car in snow for the first time last week, so that was fun.
Posts: 3003 | Registered: Oct 2004
| IP: Logged |
posted
Working is good, usually. Settling in to life is good, too, usually. Losing your car in snow - that can be fun! I've done that, um, a lot of times. Not lately, of course...
Posts: 8355 | Registered: Apr 2003
| IP: Logged |