Nullmailer

nullmailer is an relay-only forwarding MTA (Mail Transfer Agent). That means that all incoming emails on a system will get forwarded to a configured external mail server. This can be useful if a installation of a local email server is not wanted or not really useful but at least system emails need to get forward somewhere.

You can use nullmailer with every (external) email provider. Note, some free providers have limitations on the amount of emails you can send per day or month!

Installation

$ sudo apt-get install nullmailer mailutils

Configuration

Basically you can configure nullmailer by modifying the configuration files in /etc/nullmailer, in detail these are the files

For more details on this see below and / or also the man pages for nullmailer(7), nullmailer-queue(8) and nullmailer-send(8).

Or you can simply use the debconf utility to configure / modify the configuration.

$ sudo dpkg-reconfigure nullmailer


Installation Examples - GMail

  1. Preparation: Create a dedicated App-Password for nullmailer

  2. Setup the configuration files. Please use your data for GMail email login!
    $ sudo sh -c "echo $(hostname --fqdn) > /etc/nullmailer/defaultdomain"
    $ sudo sh -c "echo 'target-email-address@your-domain.net' > /etc/nullmailer/adminaddr"
    $ sudo sh -c "echo 'smtp.gmail.com smtp --auth-login --port=587 --starttls --user=your-name@gmail.com --pass=your-password' > /etc/nullmailer/remotes"
    $ sudo chmod 600 /etc/nullmailer/remotes
  3. Check the configuration by sending a test email.
    $ echo "hello" | NULLMAILER_NAME="Testsytem check" mail -s "This is just a test with nullmailer" "target-email-address@your-domain.net"


Installation Examples - T-Online

  1. Preparation: No special things needed, there is no 2FA like GMail is doing
  2. Setup the configuration files. Please use your T-Online login data!
    $ sudo sh -c "echo $(hostname --fqdn) > /etc/nullmailer/defaultdomain"
    $ sudo sh -c "echo 'target-email-address@your-domain.net' > /etc/nullmailer/adminaddr"
    $ sudo sh -c "echo 'securesmtp.t-online.de smtp --port=587 --starttls --user=your-user@t-online.de --pass=your-password' > /etc/nullmailer/remotes"
    $ sudo chmod 600 /etc/nullmailer/remotes
  3. Check the configuration by sending a test email.
    $ echo "error" | NULLMAILER_NAME="Testsystem check" mail -s "This is just a test with nullmailer" "target-email-address@your-domain.net"


Problems

The most typical problem is simply nullmailer can't login into your email provider to deliver one or more emails. This is easy to check by looking at the current status of the nullmailer service.

$ sudo service nullmailer status
● nullmailer.service - LSB: relay-only mail transport agent
   Loaded: loaded (/etc/init.d/nullmailer; generated; vendor preset: enabled)
   Active: active (running) since Fr 2019-08-02 09:14:15 CEST; 10h ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1965 ExecStart=/etc/init.d/nullmailer start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/nullmailer.service
           └─2000 /usr/sbin/nullmailer-send -s

Aug 02 09:14:15 my-host nullmailer[1965]: Starting mail-transfer-agent: nullmailer.
Aug 02 09:14:15 my-host systemd[1]: Started LSB: relay-only mail transport agent.
Aug 02 09:14:15 my-host nullmailer[2000]: Rescanning queue.
Aug 02 19:44:43 my-host nullmailer[2000]: Trigger pulled.
Aug 02 19:44:43 my-host nullmailer[2000]: Rescanning queue.
Aug 02 19:44:43 my-host nullmailer[2000]: Starting delivery: protocol: smtp host: smtp.gmail.com file: 1564767883.13909
Aug 02 19:44:43 my-host nullmailer[2000]: Starting delivery, 1 message(s) in queue.
Aug 02 19:44:44 my-host nullmailer[13910]: smtp: Failed: 535-5.7.8 Username and Password not accepted. Learn more at
                                               535 5.7.8  https://support.google.com/mail/?p=BadCredentials i13sm69632383wrr.73 - gsmtp
Aug 02 19:44:44 my-host nullmailer[2000]: Sending failed:  Permanent error in sending the message
Aug 02 19:44:44 my-host nullmailer[2000]: Delivery complete, 1 message(s) remain.

More details on issues that happen while nullmailer is trying to deliver emails can be found in /var/log/mail.err.


Security Note

Please keep in mind that every user in the group sudo will be able to view the email contact data for nullmailer! For systems where having multiple users access to nullmailer will probably not the best solution for forwarding system emails! Keep sure /etc/nullmailer/remotes is only readable for the user root!


CategoryNetwork CategoryMail CategorySoftware CategorySystemAdministration