I have a shell script which will in-turn invokes a perl script. THe perl script has a mail sending functionality. The script runs very well when i run it manually from command prompt and delivers the mail also, while when scheduled from crontab the shell and perl both runs as per the log, but mail is not getting delivered.
Please find below code snippet
Shell Script :rmail.sh
#!/bin/sh
. /home/pm_prod/.bash_profile
export PATH=$PATH:/home/orapps/client/oracle/product/10.2.0/client_1/bin:/usr/kerberos/bin:/data2/software/oracle/product/10.2.0/client_1/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/pm_prod/bin/:
perl /home/pm_prod/PM/bin/ALERT/rmail.pl
Shell Script :rmail.pl
#!/usr/bin/perl -w
use strict;
use Mail::Sender;
# Send the file. Change all variables to suit
my $sender = new Mail::Sender
{
smtp => 'some.smtpserver.com',
from => 'somename@somedomain.com'
};
$sender->MailFile(
{
to => 'somename@somedomain.com',
subject => 'File',
msg => "Here is the data.\n",
file => '/home/pm_prod/PM/bin/ALERT/attachement_file.txt',
});
CronTab Entry
* * * * * sh /home/pm_prod/PM/bin/ALERT/rmail.sh
Please help me