Installing and Configuring Postfix

Content:

The core component in a mail server is the MTA, or message transport agent. The role of an MTA is to transport messages from a server, to the client, and vice-versa.

It can be installed using

apt install postfix

During the install process, you’ll be asked a few configuration questions. Skip these for now, as you’ll need to re-run the configuration tool anyway once complete. There are a lot of important configuration options which are left out of the post-install process.

Once the installation is complete, re-run the configuration tool using

dpkg-reconfigure postfix

You’ll see a similar config window as before, but this time there will be extra settings included later on.

Let’s break down each setting step by step.

General Type of Mail Configuration

mail server type
Mail configuration options.

This first setting asks us to confirm the type of mail configuration we will be using. For a general email server, the correct option is Internet Site.

System Mail Name

mail server domain
System mail name dialog.

The system mail name needs to be set to the domain name we’ll be using for emails. It will be used internally to qualify email addresses that do not have a domain attached. That is, if we send an email from the user called ‘user’, without specifying a domain, the system will attach it automatically.

Root and Postmaster Mail Recipient

mail server user

Root and postmaster mail recipient dialog.

Set the user that will receive emails directed towards root@ and postmaster@. We recommend setting this to the username of your main user.

Other Destinations to Accept Mail For

destinations
Other destinations we’ll receive emails for.

Adds other names used to identify this system. This will be pre-filled with local hostnames, such as ‘localhost’. If messages are received by Postfix addressed to any of the listed domains, Postfix will determine itself to be the destination.

Some system applications will use a mail client (if there is one installed) to send system messages to the sysadmin. You can leave this set to the pre-filled values.

Force Synchronous Updates on Mail Queue?

sync
Synchronous mail updates dialog.

Synchronous updates are considered a safer, but slower way to receive emails. In practice, you’re almost certainly using the ext4 filesystem (which is journaled), so you don’t need this turned on.

Local networks

local networks
Local networks setting.

Sets the local IP addresses used by Postfix. If you’re using IPv6 and IPv4, you can leave this set to the pre-filled default. If you’re only using IPv4, delete all but 127.0.0.0/8.

Mailbox Size Limit

size
Setting the mailbox size limit.

Configures the maximum allowed size for mailboxes, in bytes. You can choose to set this, but we suggest setting this to 0 (unlimited) to ensure emails are not missed in the future.

If you manage your mailbox, size shouldn’t become an issue.

Local Address Extension Character

extension character
Local address extension character.

When setting up your email address, you can add an extension character that allows for unique addresses, without having to set up new mailboxes.

For example, with the ‘+’ extension character

user@example.com
user+1@example.com
user+paypal@example.com

will all end up in the mailbox for ‘user@’. It can be a useful way of defining unique email addresses for services. Set this if you want to use it, the default of ‘+’ is often fine.

Internet Protocols to Use

protocols
Setting Postfix internet protocols.

Defines the internet protocols Postfix will use. If your server only supports IPv4, choose ‘ipv4’. Otherwise, select ‘all’.

By default, your email account names will map 1 to 1 with your email addresses. A system with the users bob, mary and david will have the email addresses bob@, mary@ and david@. root@ and postmaster@ will also be valid, and directed to the mailbox of the user specified in the config.

Once complete, either restart the system, or run systemctl reload postfix to apply the new configuration.

There are a lot more configuration options available, some of which are covered in other posts. For now, we have the basic setup we need to start sending and receiving emails.