[CentOS] Cron sending to root after changing MAILTO

Thu Jul 20 14:57:32 UTC 2017
Valeri Galtsev <galtsev at kicp.uchicago.edu>

On Thu, July 20, 2017 8:54 am, Richard wrote:
>
>> Date: Thursday, July 20, 2017 02:25:52 +0000
>> From: Richard <lists-centos at listmail.innovate.net>
>>
>>> Date: Wednesday, July 19, 2017 23:31:10 +0000
>>> From: Chad Cordero <ccordero at csusb.edu>
>>>
>>> It’s being rejected before it even reaches the mailbox, so
>>> forwarding won’t work.  Crond should really be using the MAILTO
>>> variable and it’s not.
>>>
>>
>> In my testing, this worked as advertised. Changing the "MAILTO=" in
>> /etc/crontab from the default "root" to either a local username or a
>> remote address resulted in the crontab messages being delivered to
>> the desired mailboxes. I think I'd put a test command into the
>> crontab and watch the logs to see what might be going on --
>> including making certain that the crontab is reloading correctly
>> after changing the "mailto" value.
>>
>> Separately, but related, did you run newaliases or postalias after
>> you added the entry to "root:" in /etc/aliases?
>>
>
> Re-reading earlier messages, are the commands in question being
> invoked out of /etc/crontab, /etc/cron.daily, etc. or  user-level
> crontabs?
>
> The "mailto" value is crontab file specific, so setting it in
> /etc/crontab would only effect commands run from there (a file that
> isn't used much any longer). As the /etc/cron.daily, etc. jobs are
> now run from /etc/anacrontab you'd need to adjust the "mailto" in
> that file for things run that way. If run from a user-level crontab
> the "mailto" needs to be in that user's crontab file. [cron.hourly is
> run out of /etc/cron.d/0hourly, not anacrontab, and has its own
> "mailto".]

There are many things one can do as far as root mail is concerned... The
best in my book is the smallest, easiest, and resolving everything. Which
is (as suggested already I bet more than once): add to the end of
/etc/aliases the line

root: person at some.mail.server

( and don't forget to: newaliases && postfix reload )
where "person at some.mail.server" is real e-mail address that works, of a
real person who does read mail at that address, and ideally there should
be no spam/virus etc filtering on that. There should be person who should
ideally read everything that ends up sent to root! Note, that with postfix
as MX making alias (usually to non-privileged user on the same box;
ideally that shouldn't be sent over internet) for root's email is
mandatory. Root account should not receive e-mail for security reasons.
However, e-mail sent by system tasks is to be checked by sysadmin. Also:
there are several e-mail accounts that should exists and accept mail; on
MX box: postmaster is one of them. If that MX is responsible MX for
domain, there also should be hostmater, security, and abuse. (Please, read
RFCs for all details, too much to cite, and I definitely will miss
something ;-) All of these by default are aliased to root, so root's
e-mail has to be accepted and all of it should be delivered to a person
(or persons).

I hope, this helps.

Valeri

++++++++++++++++++++++++++++++++++++++++
Valeri Galtsev
Sr System Administrator
Department of Astronomy and Astrophysics
Kavli Institute for Cosmological Physics
University of Chicago
Phone: 773-702-4247
++++++++++++++++++++++++++++++++++++++++