Jonathan Dowland <j...@debian.org> writes: > On Wed, Oct 17, 2018 at 08:33:47PM -0700, Russ Allbery wrote: >>MAILTO was the main thing that I remember missing in terms of pure >>functionality. > > This is not a complete substitute for all uses of MAILTO, but I found > the following useful so I share it in case you weren't aware of it. > > Define a service specifically designed for sending status emails: > > status-email-user@.service: >> [Service] >> Type=oneshot >> ExecStart=-/usr/local/bin/systemd-email %i >> User=nobody >> Group=systemd-journal > > (I also switch on a little status LED I have with another ExecStart > line) > > /usr/local/bin/systemd-email: >> systemctl status --full "$1" | mail -s "unit $1 failed" root > > Put an OnFailure= line in systemd units that you want to mail you if > they go wrong > >> [Unit] >> OnFailure=status-email-user@%n.service
But this not play well with exim4. See: https://lists.freedesktop.org/archives/systemd-devel/2018-September/041417.html (and thread as a whole) KJ -- http://stopstopnop.pl/stop_stopnop.pl_o_nas.html Disks travel in packs.