When configuring a standalone Linux mail server with Postfix, a common roadblock is encountering the bounce message "domain of sender address does not exist." This typically occurs when your server attempts to send emails using a non-FQDN (Fully Qualified Domain Name) like root@domain.local
that lacks proper DNS resolution.
The primary solution involves modifying your /etc/postfix/main.cf
file to establish proper sender domains. Here's the critical configuration:
# Set your actual internet domain myorigin = yourdomain.com mydomain = yourdomain.com # For systems without permanent internet domains myhostname = mail.yourdomain.com mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain # Important for sender validation smtpd_sender_restrictions = permit_mynetworks, reject_unknown_sender_domain
For a development server that needs to send legitimate emails, you might use this setup:
# Force all outgoing mail to use valid domain sender_canonical_maps = regexp:/etc/postfix/sender_canonical # Content of /etc/postfix/sender_canonical: /^root@.*$/ noreply@yourdomain.com /^.*@domain.local$/ noreply@yourdomain.com
Ensure your domain has proper DNS records:
- MX record pointing to your mail server
- Reverse PTR record matching your hostname
- SPF record authorizing your server
After making changes, verify and apply them:
postmap /etc/postfix/sender_canonical postfix check systemctl restart postfix
To test your configuration:
echo "Test email" | mail -s "Postfix Test" recipient@example.com tail -f /var/log/mail.log
When configuring a standalone Linux mail server using Postfix, you might encounter bounce messages stating "domain of sender address does not exist." This typically occurs when emails are sent from addresses like root@domain.local
where the domain isn't properly registered or configured in DNS.
The primary files you'll need to modify are:
/etc/postfix/main.cf /etc/postfix/generic /etc/hostname /etc/mailname
First, ensure your system's hostname and mail domain are correctly set:
# Set the hostname (replace with your actual domain) sudo hostnamectl set-hostname mail.yourdomain.com # Set the mail name echo "yourdomain.com" | sudo tee /etc/mailname
Edit /etc/postfix/main.cf
with these critical settings:
myhostname = mail.yourdomain.com mydomain = yourdomain.com myorigin = $mydomain inet_interfaces = all mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain relayhost = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 smtp_generic_maps = hash:/etc/postfix/generic
Create/edit /etc/postfix/generic
to map local addresses to proper domain addresses:
root@localhost root@yourdomain.com root@mail.yourdomain.com root@yourdomain.com @localhost @yourdomain.com
Then compile the map:
sudo postmap /etc/postfix/generic
For proper email delivery, your domain must have these DNS records:
yourdomain.com. IN MX 10 mail.yourdomain.com. mail.yourdomain.com. IN A 192.0.2.1 (your server IP)
Additionally, consider setting up:
- SPF record
- DKIM record
- DMARC record
After making changes, always reload Postfix:
sudo systemctl reload postfix
Test email sending:
echo "Test email body" | mail -s "Test Subject" recipient@externaldomain.com
If problems persist, check:
# View mail queue postqueue -p # Check logs tail -f /var/log/mail.log
For better deliverability:
# In main.cf smtpd_tls_security_level = may smtp_tls_security_level = may smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key