====== Install and Configure Postfix as a Send-Only SMTP Server ======
- Start with a fully updated and configured Ubuntu server.
- Install Postfix
sudo debconf-set-selections <<< "postfix postfix/mailname string `hostname -f`"
sudo debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'"
sudo apt-get install -y mailutils
- Restart Postfix with ''sudo service postfix restart''
- Forward System Emails:
cp /etc/aliases /tmp/
cat >> /tmp/aliases << EOF
root: user@example.com
EOF
sudo mv /tmp/aliases /etc/aliases
sudo chown root:root /etc/aliases
sudo newaliases
- Test sending an email:
echo "Test body" | mail -s "Subject Line" root