Setting MAILTO=user@example.org in /etc/cron.daily/foo does not work. The script output is not sent to user@example.org .
The page at http://www.unixgeeks.org/security/newbie/unix/cron-1.html also suggests a simple solution:
The file /etc/cron.daily/foo now contains the following:
#!/bin/sh
/usr/bin/script 2>&1 | mailx -s "$0" stefanl@example.org
This will send an email to 'stefanl@example.org' with the subject which is equal to the full path of the script (e.g. /etc/cron.daily/foo).
Here's what Unixgeeks.org says about this:
Output from cron
As I've said before, the output from
cron gets mailed to the owner of the
process, or the person specified in
the MAILTO variable, but what if you
don't want that? If you want to mail
the output to someone else, you can
just pipe the output to the command
mail. e.g.
cmd | mail -s "Subject of mail" user
Sometimes, I only want to receive the errors from a cronjob, not the stdout, so I use this trick. The syntax may look wrong at first glance, but rest assured it works. The following cronjob will send STDOUT to /dev/null, and will then handle STDERR via the pipeline.
doit 2>&1 >/dev/null | mailx -s "$0" stefanl@example.org
Same thing, but send to syslog:
doit 2>&1 >/dev/null | /usr/bin/logger -t $ME
Also see my answer on ServerFault to Cronjob stderr to file and email