Configuring nullmailer on Arch Linux to relay email via Gmail
Configuring nullmailer on Arch Linux to relay email via Gmail

I’ve been a fan of nullmailer for some years now, so much so that I took ownership of the nullmailer package for Arch Linux.

nullmailer is a sendmail/qmail/etc replacement MTA for hosts which relay to a fixed set of smart relays. It is designed to be simple to configure, secure, and easily extendable.

The other advantage nullmailer has compared to similar tools is that is queues email until it is able to deliver it upstream.

Install nullmailer as follows.

packer -S --noedit --noconfirm nullmailer

Configuring nullmailer to relay via Gmail can be achieved using SMTPS or MSA. nullmailer has had these capabilities since 1.10. The following provides some useful clues /usr/lib/nullmailer/smtp --help.

While these examples are specific to relaying via Gmail, you can see it is trivial to adapt them to any other mail host.

Relay via Gmail using MSA

Add to following to /etc/nullmailer/remotes. I prefer this technique. smtp --port=587 --auth-login --pass=Yourpassword --starttls

Relay via Gmail using SMTPS

Add to following to /etc/nullmailer/remotes. smtp --port=465 --auth-login --pass=Yourpassword --ssl

Once you’ve got /etc/nullmailer/remotes configured start the nullmailer service.

sudo systemctl start nullmailer

To test nullmailer can relay email correctly do the following.

echo "Test 1" | mailx -s "Test One"

You can see what nullmailer is up to by checking the systemd journal or syslog (if you’ve syslog enabled systemd). This is how to get the logs from the systemd journal.

journalctl _SYSTEMD_UNIT=nullmailer.service

Or via syslog.

sudo grep nullmailer /var/log/daemon.log

When you’re happy nullmailer is working enable the systemd unit.

sudo systemctl enable nullmailer

Email will now flow as required.