Hi,
I am building a web interface to run a series of shell scripts that reside on the web server. The bash script are written such that they can be used independently for the task they are meant for, or the same scripts can be run from this web UI. The scripts are mostly for doing software builds, testing, and uploading to another server. The webpage issues a call out to a tiny PHP script that calls the bash shell script. In one of the scripts I am trying to add the ability to send an e-mail with sendmail when a software build fails. It looks something like this:
---------------------------------------------------------------------------------------
DistributionList="me@mydomain.com";
MessageFile="/tmp/build_failure_email.txt";
if [ -e $MessageFile ];
then
rm $MessageFile
fi
#echo "To: $DistributionList" >> $MessageFile;
Subject="My Subject...";
echo "Subject: ${Subject}" >> $MessageFile;
FromName="My Name";
FromAddress="me@mydomain.com";
echo "From: $FromName <${FromAddress}>" >> $MessageFile;
echo "Message Body line 1..." >> $MessageFile;
echo "Message Body line 2." >> $MessageFile;
/usr/sbin/sendmail "$DistributionList" < $MessageFile
#/usr/sbin/sendmail -t "$DistributionList" < $MessageFile
---------------------------------------------------------------------------------------
When I run this script from the command line it works perfectly fine! No errors, and I get the e-mail, all is good in the world.
Now when I invoke the SAME script file via the web UI it produces the following error:
"SendMail: fatal: Recipient addresses must be specified on the command line or via the -t option"
As you can see I AM specifying the address on the command line, and I have also tried it with -t and putting the address in the file. But neither way works when the bash script is called from apache by way of the PHP script. I have spent hours trying to figure this out with no luck. Note, this is all running on Mac OS X. Can anyone provide any assistance, or pointers to relevant informaion?
Note, when I run the script manually from a Terminal window (when it works) I am logged in as an administrative user (not root), call it user_a. Apache is set in its config file to also run as the same administrative (non-root) user, user_a. (And yes I confirmed it is indeed running as that user.) The sendmail command is just a line in the bash script so it should be running as the same user that invokes the script - that would be the user apache is running as - or user_a.
Also, when googling this error it turns up a lot of pages about PHP & Drupal and setting the PHP.ini file to use the -t flag when calling sendmail. But that has nothing to do with my problem. My call to sendmail is not occurring from inside PHP, to be clear, it is inside a bash script that gets called by PHP.
Any help would be greatly appreciated.
THANKS!
MacQAGuy