Managing cron and similar E-Mails from headless systems

Robert Heller heller at deepsoft.com
Fri Feb 17 18:06:13 UTC 2017


At Fri, 17 Feb 2017 11:00:16 -0500 "Ubuntu user technical support,  not for general discussions" <ubuntu-users at lists.ubuntu.com> wrote:

> 
> On Friday 17 February 2017 06:14:01 Chris Green wrote:
> 
> > I have several headless systems doing useful work around the place:-
> >
> >     A Raspberry Pi providing local DNS and DHCP
> >
> >     A Beaglebone Black on our boat monitoring temperatures and
> > batteries
> >
> >     An old desktop doing backups in the garage
> >
> >     etc.
> >
> >
> > Most of these have one or more cron jobs running periodic rsync
> > backups, copying data, etc.  If the cron job has an error then it
> > sends E-Mail to the owner of the job ('chris' in most cases, might be
> > root in a couple).
> >
> > It's (moderately) easy to set up an MTA and /etc/aliases so that the
> > messages are sent to my normal E-Mail.  However I can't come up with a
> > straightforward way of indicating where the messsage is *from*.
> >
> > You can't just invent a domain name for the headless system because
> > that gets the E-Mail rejected by intermediate systems that try and
> > look up the sender host name.  Cron doesn't seem to have any mechanism
> > for setting the sender's name, cron errors just come from 'root@'.
> >
> > Can anyone suggest a neat way of handling this so that I know where
> > the errors are coming from?
> >
> > --
> > Chris Green
> 
> A hosts file based home network should suffice to fix that. I did have it 

The OP is already running a DNS server, so he really does not need to bother 
with a hosts file.

I expect the problem is that he is sending these E-Mails off the local LAN to 
some E-Mail address "in the cloud" and spam filters are going to reject them 
because the From: header will be wonky (like root at rpi3.my.local.domain).

What he needs to do is set up a "gateway" system -- one of the machines on the
LAN needs to be set up as an outbound SMTP server for the LAN and needs to
Masqurade the addresses (eg rewrite the From: header) to something sane, like
his personal E-Mail address and add an X-Orig-From: headr line with the
original From: header. Or else set up a procmail recipe (on of the machines on
the LAN) that forwards the messages from his personal address.

> setup to do that from 3 of the now 5 machines here, but the inability to 
> separate the messages into important turned the whole thing into spam 
> for me. Set your resolv.conf to include the commands:
> "nameserver local.address.of.router"
> and:
> "order hosts,dns"
> 
> So it will look at /etc/hosts first, failing to find a match there it 
> sends it to the router, which forwards it to your ISP's dns.
> 
> 1. Set the hostname and domain name of your machines so they know who 
> they are.
> 
> 2. run the same hosts file on all machines, which lists the local ip, 
> names, and aliases of the whole local network, 7 lines here plus the 
> obligatory localhost stuff, does it nicely.  Then on the client 
> machines, I just set the MailTo: gene at coyote, and it magically appears 
> in my /var/spool/mail/gene queue. That in turn triggers a watcher script 
> to send kmail a getmail message over whatever message bus your system 
> uses, dbus here ATM, to go get the mail.
> 
> But unless you can make procmail (I use a fetchmail->procmail processing 
> chain here) send the unimportant stuff to /dev/null, you'll likely tear 
> it back down in a week or 2. You don't need to know, when logging into 
> one of the other machines, everytime you fat fingered the password. With 
> my short fat fingers, and 82 years of arthritis accumulated, very easily 
> done.
> 
> Cheers, Gene Heskett

-- 
Robert Heller             -- 978-544-6933
Deepwoods Software        -- Custom Software Services
http://www.deepsoft.com/  -- Linux Administration Services
heller at deepsoft.com       -- Webhosting Services
            




More information about the ubuntu-users mailing list