Score:0

Cron: MAILTO for all cronjob notifications to an external address uses the wrong `to` header

mp flag

My goal is to send everything that gets output from the cron daemon (no matter which crontab) to an external email address with the correct TO email header.

I set MAILTO in /etc/default/cron to MAILTO=root and set /etc/postfix/virtual to root [email protected]. This setup works, output from each crontab is delivered to [email protected], but the annoying thing is that, the TO email header does not change, it's still [email protected] - the only change is that an additional Delivered-To: [email protected] is added. Even though the message is received by the external email address I don't like the fact that I have a wrong TO - I want to have a clean and tidy setup. That means to me that I'm doing something wrong here.

If I set MAILTO in each crontab separately the correct TO header is set - but this is to much work, I have to alter each crontab, that's why I want to have a general solution.

How do I send everything that gets output from the cron daemon to an external email address with the correct TO email header?

Score:0
in flag

Typically I create a file in the root user's $HOME named .forward. In this file place the e-mail address you want all your root user mail to goto. It will catch more than just your cron output however. Any system mail going to the root user will be forwarded.

For many, many moons, this is just something I typically do on systems I manage. Drop my work e-mail into a .forward file in root's $HOME. Yes, I need a filter that puts all this mail into a folder so it won't clobber my Inbox, but it's a great way to keep track of a larger fleet of systems without logging into each machine daily to see how it's doing. Logwatch, cron, errors, other script output. All good stuff to have mailed to yourself @work.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.