postfix

Postfix is an email server. That is the software which is normally used to receive and send emails. Postfix supports the smtp protocol, which can be used to send and receive, but not for reading your mail. There are other services like pop3 or imap for that and they require further server software, which can then be configured to work together with postfix. Most of us use pre configured mail servers from free email providers and postfix can also be configured to act as a simple client for those.

Simplest use case: Postfix as a mail client

Cron jobs and custom scripts often use local accounts for monitoring purposes tend to send mails to different local users. A file called /etc/aliases redirects mails and often comes pre configured so, that root receives all mails. Services like smartd want a way to inform you about hard disk failures, also update services might be running as cron jobs and should have the right to inform you when critical updates are available for manual installation only. Here comes how you can redirect these mails to your mail address:

Change USERNAME and PASSWORD as well as smtp.example.com and the port 25 to your needs, then set strict permissions, start postfix and send a test mail like so:

We created a file /root/.forward in which the target mail address or even addresses can be placed, but we could also have edited /etc/aliases and applied changes to that file by issuing /usr/bin/newaliases.

A complete mail server (this article is currently under construction)

The server is going to serve you smtp for sending and receiving mails, imap/pop3 to get and read your mails via an email program, on server anti spam handling and sieve mail filter capabilities.

While similar setups periodically lead to exhausting step by step tutorials, I tried to to simplify everything as much as possible by dropping anything, which already comes pre-configured with postfix:

In this configuration smtpd_sasl_type and virtual_transport are the key for understanding what it actually does: Dovecot is used for authentication in which case smtpd_relay_restrictions will allow sending mails to other servers (which is called relay). The other way round when receiving mail dovecot also gets used over the lmtp protocol. Therefore we will now see how dovecot’s lmtp configuration must look like:

Commands

postmap virtual – recreates the virtual.db from virtual
postfix reload – reload configuration files

max,