Configure nullmailer with a relay host

If you wish to receive status updates from your Debian or Ubuntu system, you need to install and configure a mail transfer agent (MTA). nullmailer is a relay-only forwarding MTA that can be used as an alternative to more complex MTAs, such as Exim, Sendmail or Postfix.

A relay host, also referred to as a smarthost, can be defined as an email server for outgoing mail that is being afforded a good reputation by its peers. In this example, we use Fastmail because email deliverability depends on a number of different factors.

Configuration of nullmailer with Email Service Providers (ESPs) other than Fastmail should be similar, given that all ESPs implement the Simple Mail Transfer Protocol (SMTP).

Step 1

Generate an app password

Log into your Fastmail account and set up a new app password for SMTP authentication.

Create an alias

Set up a dedicated Fastmail alias to receive incoming messages.

Step 2

Use copy and paste to enter the following commands. Be careful not to miss any punctuation.

Create the new directory /etc/nullmailer and the file /etc/nullmailer/adminaddr.

$ sudo mkdir /etc/nullmailer && sudo nano /etc/nullmailer/adminaddr

The Fastmail alias you created in Step 1 should be the only entry in /etc/nullmailer/adminaddr.

target.email@fastmail.com

Step 3

Install the required packages.

$ sudo apt-get install --yes nullmailer mailutils

Step 4

Enter the system mailname. If you are setting up on a home network, you should use home.arpa as the domain name.

Configuring nullmailer

Mailname of your system:

tux.home.arpa

Ok

Configuring the smarthost

Configure nullmailer to use the Fastmail SMTP server as a smarthost. Use your Fastmail username and the app password from Step 1.

Configuring nullmailer

Smarthosts:

smtp.fastmail.com smtp --port=587 --auth-login --starttls --user=linus.torvalds@fastmail.com --pass=password

Ok

Step 5

Test your configuration with the following command.

$ echo "Test mail from nullmailer on tux.home.arpa to the local root user and forwarded on to Fastmail" | mail -s "Test nullmailer" root

Check your inbox!

Step 6

You can reconfigure nullmailer at any time by issuing the following comand.

$ sudo dpkg-reconfigure nullmailer
Click to copy