~ > which mail
/bin/mail
~ > ls -la /bin/mail
lrwxrwxrwx 1 root root 22 Feb 25 14:18 /bin/mail -> /etc/alternatives/mail
According to man mail
,
-E If an outgoing message does not contain any text in its first or only message part, do not send it but discard it silently, effectively setting the skipemptybody variable at program startup. This is useful for sending messages from scripts started by cron(8).
However, even with -E
, my cron script, which uses echo
, still sends empty messages. What happens is (essentially) this:
logmsg=""
echo "$logmsg" | mail -E -s "Log Message" me@mydomain.tld
Have I misunderstood something? Why does mail -E
send emails with empty messages?