
If you want to install Postfix on Ubuntu 26.04, this guide walks you through a clean, practical setup that works for beginners and still respects real sysadmin standards. You will learn how to install the package, choose the right mail type, configure the core settings, secure delivery with TLS, and test that mail actually works.
Postfix is one of the most trusted mail transfer agents on Linux, but a working install is more than just running apt install. A proper Postfix on Ubuntu 26.04 setup also needs correct hostname settings, sane relay rules, and a test plan so you can catch mistakes early.
This article is written like a Linux server tutorial from the point of view of a senior sysadmin. Every step explains not only how to do it, but why the step matters, so you can configure Postfix on Ubuntu 26.04 with more confidence and fewer surprises.
Prerequisites
Before you begin, make sure you have the following ready:
- Ubuntu 26.04 LTS installed on a server or virtual machine.
- Sudo or root access so you can install packages and edit system files.
- A valid hostname and domain name if the server will send or receive real email.
- Basic command-line access through SSH or local terminal.
- Optional but useful:
ufw,mailutils, andnet-toolsfor testing and firewall control.
Step 1: Update Your System
Refresh Package Lists
Start by updating the package index.
sudo apt update
This command tells Ubuntu to fetch the latest package information from its configured repositories. You should do this first because Postfix depends on system libraries, and fresh package metadata reduces install errors.
Upgrade Installed Packages
If the server is not current, upgrade it before installing Postfix.
sudo apt upgrade -y
This matters because mail services are sensitive to dependency issues. A clean base system gives you fewer surprises during setup and makes later troubleshooting much easier.
Step 2: Install Postfix
Install the Mail Server Package
Now install Postfix.
sudo apt install postfix -y
Ubuntu uses its packaged version of Postfix, which is the safest choice for most servers. You get updates through the normal package system, and that keeps maintenance simple over time.
Watch for the Setup Prompt
During installation, Ubuntu may show a configuration wizard. For most standalone servers, choose Internet Site because it lets the system send and receive mail directly in a standard SMTP role.
When asked for the mail name, enter the server’s domain or hostname that should appear in mail headers and SMTP identity. This is important because other mail systems judge your messages partly by that identity.
Step 3: Choose the Right Mail Type
Internet Site vs Other Options
Postfix may offer choices like Internet Site, Satellite System, and Local Only. For most readers who want a normal How To Install Postfix on Ubuntu 26.04 workflow, Internet Site is the right fit because it allows the server to handle mail delivery directly.
Choose Satellite System only if this machine will relay outgoing mail through another SMTP server. Choose Local Only if you just need local delivery on the host and do not plan to serve outside mail clients.
Why This Choice Matters
This is not just a setup detail. It determines how Postfix handles queues, routing, and relay rules, so picking the wrong mode can cause mail to stay local when it should leave the server, or vice versa.
Step 4: Set the Mail Identity
Check the Hostname
Confirm the server hostname first.
hostnamectl
This shows the machine’s current hostname and operating system details. You want this to match your mail identity as closely as possible because Postfix uses it in headers and server banners.
Set the Mail Name
If needed, set the system hostname to your mail server’s fully qualified domain name.
sudo hostnamectl set-hostname mail.example.com
This gives Postfix a clean identity to present to other servers. A correct hostname reduces confusion in DNS, logs, and mail delivery paths.
Verify Name Resolution
Make sure the hostname resolves locally.
getent hosts mail.example.com
This is important because Postfix should be able to identify itself consistently. If the system cannot resolve its own name, mail delivery and diagnostics become harder later.
Step 5: Verify Postfix Is Running
Check the Service
After installation, confirm that Postfix started correctly.
systemctl status postfix
You should see the service listed as active. Checking this early helps you catch startup failures before you add more settings on top.
Confirm It Is Listening
A mail server is only useful if it listens on SMTP ports.
sudo ss -tulpn | grep :25
Expected output should show Postfix bound to port 25. This matters because port 25 is the standard SMTP port for mail transfer between servers.
Step 6: Configure Postfix on Ubuntu 26.04
Open the Main Config File
Most important settings live in /etc/postfix/main.cf.
sudo nano /etc/postfix/main.cf
This file controls Postfix behavior. You change it because the default install is generic, and production mail servers need values that match your host and domain.
Set Core Identity Values
Add or adjust these settings.
myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain
myhostname tells Postfix what it is called. mydomain defines the mail domain, and myorigin controls what domain local mail appears to come from.
Define Local Delivery Domains
Set the destination domains your server should treat as local.
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
This matters because Postfix must know which messages it should deliver locally instead of forwarding elsewhere. A wrong setting here can make mail bounce or get routed in the wrong direction.
Restrict Network Interfaces
Allow Postfix to listen on the proper interfaces.
inet_interfaces = all
inet_protocols = all
This is useful when the server should accept mail on both IPv4 and IPv6. It also prevents the common mistake of leaving Postfix bound only to localhost when you expect remote access.
Control Trusted Clients
Keep relay access tight.
mynetworks = 127.0.0.0/8 [::1]/128
This limits trusted relay clients to the local machine. That is important because open relay behavior can get your server abused for spam, which can damage your domain reputation fast.
Save and Reload
After editing, reload Postfix.
sudo systemctl reload postfix
Reloading applies the new settings without dropping the service. That is a clean admin habit because it validates changes with less risk than a full restart.
Step 7: Set Maildir Storage
Enable Maildir Format
If you plan to use local mailboxes, Maildir is a practical choice.
home_mailbox = Maildir/
Maildir stores each message as a separate file. That design works well with modern mail clients and avoids some locking problems that older mailbox formats can create.
Why Maildir Is Often Better
Maildir helps when multiple tools access the mailbox at once. For a Linux server tutorial like this, it is a good default because it reduces mailbox corruption risk and fits common IMAP setups better than mbox.
Step 8: Add SMTP Authentication
Install Dovecot Support if Needed
If users will submit mail through authenticated login, Postfix often pairs with Dovecot.
sudo apt install dovecot-core dovecot-imapd -y
This matters because SMTP authentication protects your server from unauthorized relay. It also lets approved users send mail securely from clients or apps.
Enable SASL Integration
Add the relevant Postfix authentication settings.
smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
These options let Postfix hand auth work to Dovecot. That separation is useful because it keeps mailbox handling and login handling in the right place.
Why Authentication Matters
Without authentication, your server may accept only local traffic or become too open if misconfigured. With proper auth in place, remote users can submit mail safely, and you reduce the chance of relay abuse.
Step 9: Enable TLS Encryption
Add Certificate Settings
TLS protects login data and message transport.
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_security_level = may
This gives you a basic encrypted channel for testing. For production, replace the temporary certificate with a real certificate from a trusted source.
Why TLS Is Necessary
TLS stops passwords and message data from traveling in clear text. That matters because email submission often happens over public networks, and unencrypted SMTP is easy to sniff.
Force Secure Submission
For client submission, use port 587 and require encryption when appropriate.
sudo postconf -e 'submission inet n - y - - smtpd'
This helps separate mail transfer from mail submission. It is a cleaner design because server-to-server SMTP and user login traffic do not have the same security needs.
Step 10: Open the Firewall
Allow SMTP Traffic
If you use UFW, allow the mail ports you actually need.
sudo ufw allow 25/tcp
sudo ufw allow 587/tcp
sudo ufw reload
Port 25 handles server-to-server mail. Port 587 handles authenticated submission, and opening only what you need keeps the surface area smaller.
Confirm Firewall Status
sudo ufw status
This is useful because a correct Postfix config still fails if the firewall blocks the port. Firewall checks are one of the fastest ways to rule out network-level problems.
Step 11: Test the Mail Flow
Install a Mail Test Tool
A test package makes validation easier.
sudo apt install mailutils -y
This gives you a simple way to send mail from the command line. Testing matters because a service that starts cleanly can still fail during actual delivery.
Send a Test Message
echo "Postfix test on Ubuntu 26.04" | mail -s "Test mail" you@example.com
This checks whether Postfix can accept, queue, and deliver a message. It is one of the best ways to confirm the whole setup works end to end.
Check Logs
sudo tail -f /var/log/mail.log
Logs show whether Postfix accepted the message, delivered it, or rejected it. That makes troubleshooting much faster because you see the exact failure instead of guessing.
Troubleshooting
1. Relay Access Denied
This usually means the server blocked a sender that is not trusted or authenticated. Check mynetworks, SASL settings, and the submission port configuration.
2. Connection Refused on Port 25
This often points to a firewall block or a service that is not listening. Check systemctl status postfix, then confirm UFW and ss -tulpn output.
3. Mail Stuck in Queue
This can happen when DNS is wrong, the destination server is unreachable, or the relay host is misconfigured. Review mail logs first, because they usually tell you which hop failed.
4. Authentication Failed
If clients cannot log in, check the Dovecot auth socket path and the submission port rules. This problem often comes from a mismatch between Postfix and Dovecot config values.
5. TLS Errors
TLS failures usually come from bad certificate paths, wrong permissions, or a mismatch between the certificate name and the server hostname. Fix the certificate first, then reload Postfix and test again.
[su_box title=”VPS Manage Service Offer” style=”bubbles” box_color=”#000000″ radius=”10″]If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal![/su_box]