Configure send-only mailserver for Systemmails

This guide shows how to install a send-only mailserver using postfix on Debian to automatically send emails e.g. of unattended-upgrades or cron-jobs.

Postfix configuration

1. Install postfix and mailutils:

apt install postfix mailutils

2. Configure postfix as Internet site:

Then enter the systemmail-name e.g. test.server.com:

3. Verify correct host-file entry:

It is important that the first DNS name of the local server (127.0.1.1) contains the domain, otherwise some mail servers will reject the mails sent from this server because they can't verify the domain. So in our case the /etc/hosts file should look like this:

If test would stand before test.server.com the system mails could be rejected.

4. Test the configuration:

sudo echo "Postfix Send-Only Server" | sudo mail -s "Postfix Testing" <address-where-the-mail-should-be-send-to>

Set receiver address

The receiver addresses of the system mails are configured in /etc/aliases, the content can look like this:

# See man 5 aliases for format root: <target-mail-address> postmaster: root nobody: root hostmaster: root webmaster: root www: root

After changing /etc/aliases, run the following command to update the aliases database:

newaliases

Configure crontab emails

If the receiver address is properly configured through the /etc/aliases file, just add MAILTO=root to the top of each crontab file that should send emails.