Router Mail

Since most of our routers are working reliably, sometimes for years without interruption, we tend to forget about them.

We might not be aware that it needs some software-updates or has a problem with hardware or software configuration .

Therefore we want our router to tell us, whenever something is going on that we should be aware of.

Prerequisites

A dedicated SMTP user for the router on your mail server.

We assume you already created the account router@example.net on your mail server. This account has the ability to login on the Submission server and send out mails. He does not need any access to a mailbox (IMAP etc.).

Required Software

  • ssmtp - A secure, effective and simple way of getting mail off a system to your mail hub.

To install this:

router$ opkg install ssmtp

Configuration

The configuration file is located at /etc/ssmtp/ssmtp.conf:

 1     #
 2     # /etc/ssmtp.conf -- a config file for sSMTP sendmail.
 3     #
 4
 5     # The person who gets all mail for userids < 1000
 6     # Make this empty to disable rewriting.
 7     root=hostmaster@example.net
 8
 9     # The place where the mail goes. The actual machine name is required
10     # no MX records are consulted. Commonly mailhosts are named mail.domain.com
11     # The example will fit if you are in domain.com and your mailhub is so named.
12     mailhub=mail.example.net:587
13
14     # Where will the mail seem to come from?
15     rewriteDomain=router.example.net
16
17     # The full hostname
18     hostname=router.example.net
19
20     # Set this to never rewrite the "From:" line (unless not given) and to
21     # use that address in the "from line" of the envelope.
22     FromLineOverride=YES
23
24     # Use SSL/TLS to send secure messages to server.
25     UseTLS=YES
26     UseSTARTTLS=Yes
27
28     AuthUser=router@example.net
29     AuthPass=********
30
31     # Get enhanced (*really* enhanced) debugging information in the logs
32     # If you want to have debugging of the config file parsing, move this option
33     # to the top of the config file and uncomment
34     #Debug=YES

Protect the configuration, since it contains account details:

router$ chown root:mail /etc/ssmtp/ssmtp.conf
router$ chmod 640 /etc/ssmtp/ssmtp.conf

Testing

To send a test mail from the router to you:

router$ ssmtp -v -F 'OpenWRT Router' -f router@example.net "Testing Router Mail Setup" user@example.net