"MAILTO" Environment Variable is ignored when set in a file in /etc/cron.d/

Bug #1277493 reported by annunaki2k2
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
cron (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

I have a cron job definition file with the following:
----------------
# Runs every 5 minutes, logging into the proftpd database checking for expired accounts and disabling them.
MAILTO=sysadmin@[redacted].com,io@[redacted].com
*/5 * * * * root /usr/local/sbin/proftpd-expire.sh
----------------

Any output from the script ought to be emailed to both the sysadmin & io group addresses, but instead output is always sent to 'root@[local FQDN]', presumably becasue the cron job is being executed as root. For some reason, the MAILTO environment variable is being ignored, as can be confirmed when looking at the email (sent to root) for all the "X-cron-env" headers:
----------------
X-cron-env: <SHELL=/bin/sh>
X-cron-env: <HOME=/root>
X-cron-env: <PATH=/usr/bin:/bin>
X-cron-env: <LOGNAME=root>
----------------
There is clearly no MAILTO header in this email, and obviously the main proof is that this still only went to root@fqdn.

All documentation appears to say that the combination of MAILTO and a file in /etc/cron.d/ should work.

Revision history for this message
annunaki2k2 (russell-knighton) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in cron (Ubuntu):
status: New → Confirmed
Revision history for this message
Christian Kastner (ckk) wrote :

Could you check your MTA's log files (and /var/log/cron.*, if you have it) for clues as to what could be going on? I just tried this locally and it works fine: both mails are sent, and the MAILTO header is included.

Revision history for this message
Robert Schetterer (rschetterer) wrote :

I can confirm this too, specially problem with using ssmtp, cause no To: rewrite is possible there, i wrote a sendmail wrapper to fix it, some relays are unhappy with standard To: root and change i.e To: <email address hidden> which might break users mail filters.
I guess most people dont notice this cause using postfix/exim fixing the problem there, to make To: headers pretty

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.