mailto crontab doesn't work
I'm running a script on my mybookworld(NAS) via crontab every day. And it would be nice if it cou开发者_开发技巧ld send me everyday an email report with the output of the script.
So I looked at MAILTO in crontabs, but it doesn't send me anything at all. The script ran correctly at the right time, but there was no email. This is my crontab:
~ # crontab -l
MAILTO=x.y@googlemail.com
0 0 * * * python /root/erepCrawler/src/main.py
I've written a "smaller" crontab for testing reasons:
MAILTO=x.y@googlemail.com
* * * * * echo "blaah"
This should send me every minute an email with "blaah" as the body. If I'm wrong please correct me.
Is there another package needed for sending mails with crontab? sendmail is installed in /opt/sbin/sendmail.
It should work in the cron with following modifications:
MAILTO="x.y@googlemail.com"
* * * * * echo blaah
works on my server, just tested.
after spending hours debugging why this wasn't working with nullmailer on my Debian box, I discovered I had a filter at gmail sending everything from cron to "All Mail" without going through my inbox... just something to check.
I had to add this to /etc/hosts
so that mail to anyone at my server's own FQDN would be resolved:
127.0.0.1 mydomain.com.
Notice the dot at the end. In my case, I'm sending email essentially to root@localhost with MAILTO=root
which gets translated to root@mydomain.com.
Here's some more detail on this answer.
精彩评论