develooper Front page | perl.perl5.porters | Postings from April 2000

perl execution problem

Thread Next
Gavin Minor
April 12, 2000 23:30
perl execution problem
Message ID:
The following code, when executed, does not work.  It returns an error 
message "Couldn't finish running sendmail: aborting at sendmail.cgi line 
28." (note line 28 is the close(SENDMAIL) line)

Can anyone suggest why this may not be working?


use CGI;
use CGI::Carp qw(fatalsToBrowser);

my $sendmail = "/usr/sbin/sendmail -t";
my $reply_to = '';
my $subject  = "Test Email";
my $content  = "This is a Test Email";
my $to       = '';
my $from     = '';

print "Content-Type: text/html\n\n";
print "<html> <head>\n";
print "<title>Sending Mail</title>\n";
print "</head>\n";
print "<body>\n";
print "Your email is being sent...\n";

open(SENDMAIL, "| $sendmail") or die "Cannot open $sendmail: $!";
print SENDMAIL "To: $to\n";
print SENDMAIL "From: $from\n";
print SENDMAIL "Reply-to: $reply_to\n";
print SENDMAIL "X-Mailer: Perl Powered Socket Mailer\n";
print SENDMAIL "Subject: $subject\n\n";
print SENDMAIL "$content";
print SENDMAIL "\n.\n";
close(SENDMAIL) or die "Couldn't finish running sendmail: $! aborting";

print "Email has been Sent\n";
print "</body> </html>\n";

Get Your Private, Free Email at

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About