How to Set Up a Postfix Email Server
How to Set Up a Postfix Email Server
Basic Installation
# Ubuntu/Debian
apt update
apt install postfix mailutils -y
# CentOS/AlmaLinux
dnf install postfix mailx -y
During installation, select Internet Site and enter your domain (e.g., yourdomain.com).
systemctl start postfix
systemctl enable postfix
Configuring Postfix
Edit /etc/postfix/main.cf:
myhostname = mail.yourdomain.com
mydomain = yourdomain.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
Restart Postfix:
systemctl restart postfix
Testing
echo "Test email body" | mail -s "Test Subject" [email protected]
Check /var/log/mail.log (Ubuntu/Debian) or /var/log/maillog (CentOS) for delivery status.