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

Can't get script to work?????

Status
Not open for further replies.

BlckJckFrnk

Technical User
Feb 20, 2002
83
0
0
US
I'm a novice when it come to script wrting. Been trying to get the below script to work, but no luck. Would appreciate any help.



#!/usr/bin/perl

Print "Content-type:text/plain","\n\n";

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
$mailprog = '/usr/bin/sendmail';

$recipient = 'Frank\@thacherxxxxxx.com';

open MAIL, "|$mailprog -t Frank\@thacherxxxxxx.com" || dienice "Can't access $mailprog!\n";

print MAIL "To: Frank\@thacherxxxxxx.com";

print MAIL "Reply-to: Frank\@thacherxxxxxx.com\n";

print MAIL "Subject: Form Data\n";

print MAIL "Firstname=$FORM{'Firstname'}\n;
print MAIL "Lastname=$FORM{'Lastname'}\n;
print MAIL "Company=$FORM{'Company'}\n;
print MAIL "Address1=$FORM{'Address1'}\n;
print MAIL "Address2=$FORM{'Address2'}\n;
print MAIL "City=$FORM{'City'}\n;
print MAIL "State=$FORM{'State'}\n;
print MAIL "Email=$FORM{'Email'}\n;
print MAIL "Telephone=$FORM{'Telephone'}\n;
print MAIL "Comments=$FORM{'Comments'}\n;

close(MAIL);


print
<html><body>
<h2>Thank you for Contacting Thacher. <a href="/Homepage.htm">home page</a>.
</body></html>


sub dienice {
($errmsg) = @_;
print "<h2>Error</h2>\n";
print "$errmsg<p>\n";
print "</body></html>\n";
exit;
}
 
Can you be more specific in what is going wrong?

I am almost betting it has to do with using sendmail directly...

If this is the case my opinion is, as always, switch to Net::SMTP. you'll be much better served, more compatible with maintainable, debuggable code that doesn't have OS dependancies.
 
print MAIL "To: Frank\@thacherxxxxxx.com[red]\n[/red]";


Kind Regards
Duncan
 
Yea , typical sendmail problems.

Check your path to sendmail, check the return result of sendmail, see what sendmail is barfing on.

Even better, convert to Net::SMTP and all these problems disappear. You'll be standards compliant, OS independant and have debuggable code.
 
Duncan is right - but siberian is, I think, righter (sic)

No OS Dependancies = A Good Thing

Mike

"Deliver me from the bane of civilised life; teddy bear envy."

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

 
Thanks for the feedback... No matter what I do/correct/try I get the 500 server error.

after looking at some of the other threads and was thinking about trying STMP. I'll give it a try...Thanks Again


 
Code:
print MAIL "Subject: Form Data\n";

Should have two /n/n;

Code:
print MAIL "Subject: Form Data\n\n";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top