Hello,
I need some help related to this topic if anyone is still monitoring this thread. My problem is similar to this and in googling for information came upon this thread.
I have a shell script that sends a simple email from user root. The aim is to eventually use this mechanism for sending health check information from the machine. The domain the machine resides is not externally known; ie it is on an internal LAN. For example say its hostname is
machine1@internal.company.com. Without setting the EMAIL environment variable mutt sends the email to a local SMTPD server for forwarding as
root@internal.company.com. This causes the final mail system to reject the mail (rules to stop spamming etc) because it can not resolve the domain internal.company.com.
So in the script I coded 'export EMAIL="myname@realdomain.com"' and when run in the foreground in a bash interactive shell the email is accepted by the final mail system and it is received correctly.
However if I run this same script under CRON it is as though mutt ignores the EMAIL environment variable and sends the email as though it is from
root@internal.company.com.
The script looks like this:
export EMAIL="myname@realdomain.com"
EMAILTO="recipient1@otherdomain.com"
SUBJECT="$(hostname) test"
mutt -s "${SUBJECT} ${EMAILTO} </tmp/message.txt
BTW my ~/.muttrc for root looks like this (but does not appear to make any difference if I have the -f or not for sendmail)
set sendmail="/usr/sbin/sendmail -oem -oi
-fmyname@realdomain.com"
It appears, to me, that mutt ignores the EMAIL environment variable when it is invoked from a shell that is not interactive. Has anyone else seen this behaviour? Could this be an anti-spamming mechanism?
thanks
Patrick.