External mailing on FreeBSD2012-06-06 09:06
FreeBSD’s periodic sends results for daily, weekly, and monthly runs to the root user’s local inbox using the Sendmail MTA in the base system. These messages can help one identify potential issues before they blow up, such as waning disk space or security problems.
You can have your system forward this mail to an external E-mail account, such as on GMail or a private mail server, instead of reading
root’s local mbox.
To accomplish this, we’ll replace FreeBSD’s default MTA, Sendmail, with one capable of authenticating to an external SMTP server.
Stop Sendmail with
service sendmail stop, then disable it permanently in
Install a replacement MTA, OpenBSD’s smtpd, from mail/opensmtpd. Edit
smtpd.conf, configuring OpenSMTPd to listen on the local machine, map mail aliases, and deliver to local users’ mbox inboxes. With local delivery taken care of, we can add relay servers for particular domains. This example defines a relay server for GMail and for my domain using my private mail server on gigadelic.
Copy Sendmail’s alias file to OpenSMTPd’s configuration directory then edit it, uncommenting the
# root: email@example.com alias and replacing
firstname.lastname@example.org with your own personal address.
/usr/local/etc/mail/secrets and define a username and password pair for each relay server.
Create the secrets and alias databases, then enable
Now, send a test message to the local root user.
Your configuration is complete if the test message lands in your inbox. Your system will send out daily, weekly, and monthly status emails. Read on for some recommended additional settings.
Periodic can alert you to ZFS filesystem problems or failing zpools. Enable it in
S.M.A.R.T. status can be included in periodic’s daily e-mail.
As root, execute
grep -E 'ad(a)?[0-9]|(a)?cd[0-9]|da[0-9]' /var/run/dmesg.boot | grep device to list your attached detected devices. Here’s an example from
Add your desired devices to
ports-mgmt/portaudit can warn you of installed outdated ports with security vulnerabilities. Install portaudit through the ports system, then enable it in
I like the status messages for my machines to wind up in their own named folders in my IMAP inbox. If your mail server has sieve support you can use a sieve script like these to sort your mail.
Mail not arriving? As root, tail the MTA log file and watch its output as you attempt to send a message.