CloudLinux.ro
Email

How to install Postfix and Dovecot for email

Updated 7/20/2026

Postfix handles sending and receiving email (SMTP), and Dovecot handles access to mailboxes (IMAP). Together they form the base of a classic mail server.

1. Install Postfix

apt-get update -y
apt-get install -y postfix

Choose "Internet Site" and enter your domain name during configuration.

2. Install Dovecot

apt-get install -y dovecot-imapd dovecot-pop3d

3. Configure storage (Maildir)

In /etc/dovecot/conf.d/10-mail.conf:

mail_location = maildir:~/Maildir

4. Enable TLS

Email must be encrypted. Use a Let's Encrypt certificate, see free SSL certificate, and point Postfix and Dovecot to it.

5. Open the ports

ufw allow 25/tcp
ufw allow 587/tcp
ufw allow 993/tcp

Important

Manual setup is educational but laborious. For production, a solution like Mailcow is easier to maintain. Either way, configure SPF, DKIM and DMARC.

Put this guide into practice on your own VPS

EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.

See pricing

Related tutorials