Dear Monks,
Below is the code which is working fine on a number of my web applications on the same server.
But on a new application it logs "Error closing mail" and does not send an email. I do not see any difference with my other working applications and do not see how to find a bug. I checked I am passing all parameters correctly.
So any thoughts what I should check?
sub EmailBySendmail
{
my $to_ptr = shift;
my $from = shift;
my $subject = shift;
my $message = shift;
foreach my $to_ad (@$to_ptr)
{
unless(open (MAIL, "|/usr/sbin/sendmail -t"))
{
print "error.\n";
warn "Error starting sendmail: $!";
}
else
{
print MAIL "From: $from\n";
print MAIL "To: $to_ad\n";
print MAIL "Subject: $subject\n\n";
print MAIL "$message";
close(MAIL) || warn "Error closing mail: $!";
print "Mail sent.\n";
}
}
return;
}