Step 1 – Install Postfix
emerge --ask mail-mta/postfix
rc-update add postfix default
rc-service postfix start
Step 2 – Basic configuration (/etc/postfix/main.cf)
# Network
myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = all
inet_protocols = all
# Relay and destination
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
# TLS (after obtaining a certificate)
smtpd_tls_cert_file = /etc/ssl/certs/mail.example.com.crt
smtpd_tls_key_file = /etc/ssl/private/mail.example.com.key
smtpd_tls_security_level = may
smtp_tls_security_level = may
# Submission (port 587)
# Uncomment relevant lines in /etc/postfix/master.cf
# Mailbox
home_mailbox = Maildir/
mailbox_size_limit = 0
message_size_limit = 52428800
# Anti-spam basics
smtpd_helo_required = yes
smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_unauth_destination
Step 3 – Reload
postfix check
systemctl reload postfix 2>/dev/null || rc-service postfix reload 2>/dev/null || rcctl reload postfix
Step 4 – Send a test email
echo "Test body" | mail -s "Test subject" [email protected]
tail -f /var/log/maillog 2>/dev/null || tail -f /var/log/mail.log