help with send mail script
Can someone take alook at this script. I don't get meassage sent and it doesn't give an error. see below.
Thanks for your comments!
#!/usr/bin/perl
# This script should send an e-mail
print "Content-type:text/html\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 = '/var/qmail/bin/qmail-inject';
$recipient = '[email protected]';
open (MAIL, "|$mailprog -t") or &dienice("Can't access $mailprog!\n");
print MAIL "To: $recipient\n";
print MAIL "Reply-to: $FORM{'email'} ($FORM{'name'})\n";
print MAIL "Subject: Form Data\n\n";
# krb print info from form to mail message.
foreach $key (keys(%FORM))
{
print MAIL "$key = $FORM{$key}\n";
}
close(MAIL);
#added to assess problems- krb!!!!!
print "Form Diagnostics";
print "Diagnostics for send mail form\n";
print "Referer = $ENV{'HTTP_REFERER'}\n";
print "Caller = $ENV{'CONTENT_LENGTH'}\n";
print "";
# Notify mail has been delivered - krb
print "";
print <Thank You
Thank you for writing. Your mail has been delivered.
Return to our home page.
EndHTML
sub dienice
{
($errmsg) = @_;
print "Error\n";
print "$errmsg\n";
print "\n";
exit;
}
anti posted this at 13:56 — 25th January 2001.
They have: 453 posts
Joined: Jan 1999
Just a question,
where is the sender specified ?
Some MTA won't deliver it without.
And you won't get an error back.
anti
pecan204 posted this at 02:36 — 26th January 2001.
They have: 3 posts
Joined: Jan 2001
Hello,
The sender should be filled in from the form with the variable - 'email'.
If I understand that right. Is there an environment variable called sender?
Comments? Anyone.
anti posted this at 08:43 — 26th January 2001.
They have: 453 posts
Joined: Jan 1999
But the sender (From: ...) belongs in the header, that is before the empty line(\n\n).
Give it a try.
BTW:
On which system is this running ?
(BSD, Linux, Solaris ?)
syanet posted this at 18:32 — 26th January 2001.
They have: 12 posts
Joined: Dec 2000
I slighly modified this since I can't seen to get a mail script to work on my new server (RaQ3). And as with the others, it dosen't work either. ANyone see an obvious problem? I get 500 errors.
#!/usr/bin/perl
print "Content-type:text/html\n\n";
read(STDIN, $buffer, 128000);
@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/sbin/sendmail';
open (MAIL, "|$mailprog") or &dienice("Can't access $mailprog!\n");
print MAIL "To: syanet\@neo.rr.com";
print MAIL "From: $FORM{'email'}\n";
print MAIL "Reply-to: $FORM{'email'} ($FORM{'name'})\n";
print MAIL "Subject: Submission\n\n";
foreach $key (keys(%FORM))
{
print MAIL "$key = $FORM{$key}\n";
}
close(MAIL);
Syanet - Free web hosting
Coming soon.
pecan204 posted this at 02:48 — 27th January 2001.
They have: 3 posts
Joined: Jan 2001
I did just get this error.
Any comments?
syntax error at /data/pecan204/cgi-bin/send_mail.cgi line 27, near "$key ("
Execution of /data/pecan204/cgi-bin/send_mail.cgi aborted due to compilation errors.
[Fri Jan 26 18:31:38 2001] [error] [client 24.25.151.112] Premature end of script headers: /data/pecan204/cgi-bin/send_mail.cgi
[Fri Jan 26 18:31:38 2001] [error] [client 24.25.151.112] MOD_VR9: Error 500 occured while processing : /data/pecan204/cgi-bin/send_mail.cgi
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.