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 --starttls' > /etc/nullmailer/remotes"
    $ sudo chmod 600 /etc/nullmailer/remotes
  3. Check the configuration by sending a test email.
    $ echo "error" | 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="Testsytem check" mail -s "This is just a test with nullmailer" "target-email-address@your-domain.net"


Security Note

Please keep in mind that every user in the group sudo will be able to view the email contact date 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!