Aller au contenu
Email Servers

Install and Configure Postfix on Ubuntu: The Essentials

sudo apt install postfix, choose “Internet Site”, set the FQDN, then review myhostname, mydomain, mydestination and inet_interfaces in /etc/postfix/main.cf and restart.

Testé sur Ubuntu 24.04 LTS, Postfix 3.8

Postfix is the most widely used mail transfer agent on Linux: fast, secure by design and well documented. This guide installs it on Ubuntu and walks through the handful of settings you must get right.

Step 1 – Install Postfix

Terminal
sudo apt updatensudo apt install postfix
  1. When asked for the configuration type, choose Internet Site.
  2. For System mail name, enter your domain or the server’s fully qualified name, e.g. mail.example.com.
  3. Postfix installs and starts automatically.

Step 2 – Review main.cf

Terminal
sudo nano /etc/postfix/main.cf
SettingSet it toWhy
myhostnameThe server’s FQDN, e.g. mail.example.comUsed in the SMTP greeting – should match the PTR record
mydomainexample.comBase domain for other defaults
mydestination$myhostname, localhost.$mydomain, localhost, $mydomainDomains this server delivers locally
inet_interfacesall (or loopback-only for send-only servers)Which interfaces accept mail
mynetworks127.0.0.0/8 [::1]/128Who may relay without authentication – keep it tight

Step 3 – Restart and check

Terminal
sudo postfix checknsudo systemctl restart postfixnsudo systemctl status postfix u002du002dno-pager

Send a test message and watch the log:

Terminal
echo u0022Test from $(hostname)u0022 | mail -s u0022Postfix testu0022 you@example.comnsudo tail -f /var/log/mail.log

Before it goes live

A public mail server also needs TLS (smtpd_tls_cert_file / key), SASL authentication for users who send through it (usually via Dovecot), and SPF, DKIM, DMARC and PTR records – otherwise your mail will be rejected or marked as spam. Never leave it as an open relay.

Check the DNS side

Confirm MX and PTR records with the DNS Lookup tool, and authentication records with the SPF, DKIM & DMARC Checker.

Inder Kochar

Écrit par

Inder Kochar

Ingénieur systèmes et réseaux – Je rédige les solutions que j’applique chez mes clients, testées sur de vrais systèmes. Bloqué sur un problème similaire ?

Continuer la lecture

Posez une question ou partagez votre solution

Votre e-mail n’est pas publié. Les commentaires sont modérés – merci de rester dans le sujet.