Click to See Complete Forum and Search --> : Sendmail question
gaston9x19
04-14-2005, 05:40 AM
Any idea why this script doesn't seem to actually get email where I need it to go? I got all excited because the script ran without any fatal errors, but I'm still not getting email. I passed the "send_to" address in through a form. What else do I need to do to get sendmail working?
#!/usr/bin/perl
use CGI;
my $query = new CGI;
my $sendmail = "/usr/sbin/sendmail -t";
my $from = "From: gaston.glock\@gmail.com";
my $reply_to = "Reply-to: gaston.glock\@gmail.com";
my $subject = "Subject: Confirmation of your submission";
my $content = "Thanks for your submission.";
my $send_to = "To: ".$query->param('send_to');
open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";
print SENDMAIL $from;
print SENDMAIL $reply_to;
print SENDMAIL $subject;
print SENDMAIL $to;
print SENDMAIL "Content-type: text/plain\n\n";
print SENDMAIL $content;
close(SENDMAIL);
print $query->header;
print "<h3>Your email has been sent.</h3>\n";
Try this...
#!/usr/bin/perl
use CGI;
use strict;
use warnings FATAL => 'all';
my $query = new CGI;
my $sendmail = "/usr/sbin/sendmail -t";
my $from = "From: gaston.glock\@gmail.com";
my $reply_to = "Reply-to: gaston.glock\@gmail.com";
my $subject = "Subject: Confirmation of your submission";
my $content = "Thanks for your submission.";
my $send_to = "To: ".$query->param('send_to');
open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";
print SENDMAIL qq`$from
$reply_to
$subject
$send_to
Content-Type: text/plain\n\n
$content`;
close(SENDMAIL);
print $query->header, 'Your email has been sent.';
gaston9x19
04-16-2005, 10:09 PM
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@gastonglock.net and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Same thing as all those sendmail tutorials were giving me. The error log reads:
[Sat Apr 16 21:05:48 2005] [error] [client 64.35.143.40] Premature end of script headers: /home/gastong/public_html/elitedefenseforce/cgi-bin/mail2.cgi
CHMOD is definitely 755. That's not it. Kinda sucks not being able to use PERL while doiong everything right. What's up, why is it so much more complicated than PHP?
Same thing as all those sendmail tutorials were giving me. The error log reads:
[Sat Apr 16 21:05:48 2005] [error] [client 64.35.143.40] Premature end of script headers: /home/gastong/public_html/elitedefenseforce/cgi-bin/mail2.cgi
CHMOD is definitely 755. That's not it. Kinda sucks not being able to use PERL while doiong everything right. What's up, why is it so much more complicated than PHP?
Well, obviously there "is" something wrong. And usually "premature end of script headers" implies some type of permission problem.
Is this truly your path to perl?
#!/usr/bin/perl
Is this truly your path to sendmail?
/usr/sbin/sendmail
...on a side note, I once couldn't figure out why one of my scripts wouldn't run.
I forget to put the first forward slash. Took me hours to "SEE" it.
#!usr/bin/perl