Table of Contents
What you will read?
Setting up an SMTP server on Ubuntu 25.04 lets your system send emails — for alerts, password resets, cron jobs, and more. The most common and reliable way is using Postfix, a widely used Mail Transfer Agent (MTA).
Step 1: Update system packages
Before installing any new software, it’s a good idea to update your current packages to avoid dependency problems:
sudo apt update && sudo apt upgrade -y
This ensures your system is ready for a smooth Postfix installation.
Step 2: Install Postfix
Postfix is a lightweight and fast SMTP server. Installing it is simple with Ubuntu’s package manager:
sudo apt install postfix -y
When prompted, select Internet Site and enter your server’s domain name (like mail.example.com).
Step 3: Reconfigure Postfix (optional)
If you entered the wrong domain or want to change settings, you can reconfigure Postfix anytime using this command:
sudo dpkg-reconfigure postfix
It lets you modify hostname, mail type, and delivery settings interactively.
Step 4: Open SMTP ports
If you’re using UFW (Uncomplicated Firewall), you need to allow SMTP traffic on standard ports like 25 and 587:
sudo ufw allow 25
sudo ufw allow 587
Then reload the firewall rules:
sudo ufw reload
Step 5: Check Postfix status
To confirm that the SMTP service is running properly, check the Postfix system status:
sudo systemctl status postfix
You should see active (running). If not, restart the service:
sudo systemctl restart postfix