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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Sendmail

Status
Not open for further replies.

Eloff

Programmer
Aug 29, 2001
78
0
0
CA
Okay there is something badly wrong with this script. I don't know what dev/null does exactly, but without it I get a 500 error, with it the script prints out the Confirmation message but doesn't send any e-mail. I'm not sure what I did wrong but you guys will probably spot it right away.

$reply_to = "Reply-to: formhandler\@greatmasterpieces.com";
$subject = "Subject: Great Masterpieces Feedback Form";
$to = "To: eloff\@helpmygame.com";

open (MAIL, "| /usr/sbin/sendmail -t -i >& /dev/null") or die "Cannot open sendmail: $!";

print SENDMAIL $reply_to;
print SENDMAIL $subject;
print SENDMAIL $to;
print SENDMAIL "Content-type: text/plain\n\n";

read(STDIN, $input, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/,$input);
foreach $pair(@pairs){
($name, $value) = split(/=/,$pair);
$value =~ tr/+//;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/\n//g;
$value =~ s/\r//g;

$content = "$name = $value\n";

print SENDMAIL $content;
}


close(MAIL);

print "Content-type: text/html\n\n";
print "Confirmation of your submission will be emailed to you.";
Age: 17
School: Alberta Distance Learning Center
Location: British Columbia, Canada
If at first you dont't succeed, try, try again. - programmer's motto.
 
Hi Eloff <grin>

You'll kick yourself...

You're opening a process with a handle called MAIL and writing to a handle called SENDMAIL....

Just change the open and close lines to refer to SENDMAIL and you should see some results. Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Yes I noticed that going back over the program this morning. I shouldn't be writing programs past 1am:) I make stupid mistakes and then stay up hours trying to figure out what they are. Thanks. Age: 17
School: Alberta Distance Learning Center
Location: British Columbia, Canada
If at first you dont't succeed, try, try again. - programmer's motto.
 
Don't worry about it - I'm *still* making mistakes like that. Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top