FacebookTwitter
Hatrack River Forum   
my profile login | search | faq | forum home

  next oldest topic   next newest topic
» Hatrack River Forum » Active Forums » Books, Films, Food and Culture » Perl scripting help. Please. My head is going to asplode.

   
Author Topic: Perl scripting help. Please. My head is going to asplode.
Boris
Member
Member # 6935

 - posted      Profile for Boris   Email Boris         Edit/Delete Post 
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}";


Posts: 3003 | Registered: Oct 2004  |  IP: Logged | Report this post to a Moderator
Chanie
Member
Member # 9544

 - posted      Profile for Chanie   Email Chanie         Edit/Delete Post 
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 | Report this post to a Moderator
Boris
Member
Member # 6935

 - posted      Profile for Boris   Email Boris         Edit/Delete Post 
Thank you [Big Grin] I wasn't escaping the @ in the email addresses.
Posts: 3003 | Registered: Oct 2004  |  IP: Logged | Report this post to a Moderator
quidscribis
Member
Member # 5124

 - posted      Profile for quidscribis   Email quidscribis         Edit/Delete Post 
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?" [Big Grin]
Posts: 8355 | Registered: Apr 2003  |  IP: Logged | Report this post to a Moderator
Chanie
Member
Member # 9544

 - posted      Profile for Chanie   Email Chanie         Edit/Delete Post 
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 | Report this post to a Moderator
Boris
Member
Member # 6935

 - posted      Profile for Boris   Email Boris         Edit/Delete Post 
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 | Report this post to a Moderator
Boris
Member
Member # 6935

 - posted      Profile for Boris   Email Boris         Edit/Delete Post 
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?" [Big Grin]

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 | Report this post to a Moderator
quidscribis
Member
Member # 5124

 - posted      Profile for quidscribis   Email quidscribis         Edit/Delete Post 
Working is good, usually. [Smile] Settling in to life is good, too, usually. [Smile] Losing your car in snow - that can be fun! I've done that, um, a lot of times. [Big Grin] Not lately, of course...
Posts: 8355 | Registered: Apr 2003  |  IP: Logged | Report this post to a Moderator
   

   Close Topic   Feature Topic   Move Topic   Delete Topic next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:


Contact Us | Hatrack River Home Page

Copyright © 2008 Hatrack River Enterprises Inc. All rights reserved.
Reproduction in whole or in part without permission is prohibited.


Powered by Infopop Corporation
UBB.classic™ 6.7.2