I have been trying to understand why I cannot send email from a Perl Script. I have added a log funtion as to find out what is up. The hosting company I am using is a bit touchy about me poking around their log files. Here's the script:
#!/usr/local/bin/perl -T
use strict;
our($sec,$min,$hr,$mday,$m
on,$year,$
wday,$yday
,$isdst,$l
ongyr,$vmo
n,$recipie
nt,$datest
amp);
#########################
#### CONTROL MODULE #####
#########################
&procinput;
&setvars;
&sendmessage;
########################
########################
########################
##### INPUT ######
sub procinput {
($sec,$min,$hr,$mday,$mon,
$year,$wda
y,$yday,$i
sdst) = localtime(time);
$longyr = $year + 1900;
$vmon = $mon + 1;
}
sub setvars {
$ENV{HOME} = '/home/shearer';
$ENV{PATH} = '/usr/lib';
$ENV{IFS} = '';
$recipient = 'webmaster@get-onit.com';
$datestamp = ("$mon/$mday/$longyr at $hr:$min");
}
sub sendmessage {
open (MAIL, "|/usr/lib/sendmail -t -X /home/shearer/mgmt/logs/ma
il.log -v");
print MAIL "To: $recipient\n";
print MAIL "Subject: ERROR AT GET ON IT\n\n";
print MAIL "On $datestamp a request for $ENV{'REQUEST_URI'} caused an error. The users name was $ENV{'USER_NAME'}.\n";
close (MAIL);
}
The log entries that are created include the following messages:
05027 >>> collect: Cannot write ./dfi3KJjsRo005027 (bfcommit, uid=1567, gid=1569): Permission denied
05027 >>> queueup: cannot create queue file ./qfi3KJjsRo005027, euid=1567: Permission denied
/usr/lib/sendmail is a link to /usr/sbin/sendmail owned by root. The hosting company has asked me to use the link.
/var/spool/mqueue is owned by root and the mail group. permissions to /var/spool/mqueue are 755. I have not verified that this is the queue indicated in sendmail.cf.
The hosting company copied my script to a new script with www as the group but that didn't work either.
It seems to me that 2 things are needed: 1) group permissions for /var/spool/mqueue need to include write and 2) my script needs to be apart of the mail group.
What am I missing?
Thanks
Start Free Trial