Mail from your web server to addresses at your own domain never reaches the real mailbox
Fix it fast
Most common cause, 1 of 2Postfix lists your domain in mydestination
Give the server a host name of its own under the domain and keep the bare domain out of mydestination; Postfix then treats example.com as remote and delivers to its MX hosts.
sudo postconf 'myhostname=server1.example.com'
sudo postconf 'mydestination=$myhostname, localhost.$mydomain, localhost'
sudo systemctl reload postfixShort answer
When a web server can mail every domain except its own, its mail server believes it is the final destination for that domain and delivers the message on the machine, ignoring the MX record. On Postfix 3.8, take the domain out of mydestination and give myhostname a real host name; on cPanel, set Email Routing to Remote Mail Exchanger.
Which cause do you have?
Ask Postfix which domains it delivers itself, then follow one test message in the mail log. If the domain appears in mydestination, or the log shows the message handed to the local delivery agent instead of to your mail provider, the first cause applies.
postconf myhostname mydomain mydestination
hostname -f
sudo grep "to=<info@example.com>" /var/log/mail.log | tail -n 5Then find the line you see in this list and open its fix:
- 1Postfix lists your domain in mydestination
postconf shows example.com in mydestination, usually because myhostname is the bare domain or $mydomain was added to the list - 2cPanel Email Routing treats the server as the local mail exchanger
The site runs on cPanel, the domain's real MX points to an outside provider, and Email Routing shows Local Mail Exchanger
What does the error look like?
User unknown in local recipient tablePHP mail() returns true and the contact form says sent, but messages to info@example.com never reach the Google Workspace or Microsoft 365 mailbox
Cause 1 of 2
Postfix lists your domain in mydestination
You seepostconf shows example.com in mydestination, usually because myhostname is the bare domain or $mydomain was added to the list
Check
Mail to your own domain that never arrives on a Postfix server usually means the domain is in mydestination, the list of domains Postfix hands to its local delivery transport. The default is $myhostname, localhost.$mydomain, localhost, so a server whose host name is the bare domain example.com claims all of example.com, and the local agent then looks the recipient up in the system password and alias files instead of sending it to the MX.
postconf myhostname mydestinationFix
Give the server a host name of its own under the domain and keep the bare domain out of mydestination; Postfix then treats example.com as remote and delivers to its MX hosts. The postconf manual also says not to list domains that are handled elsewhere, such as virtual or backup MX domains.
sudo postconf 'myhostname=server1.example.com'
sudo postconf 'mydestination=$myhostname, localhost.$mydomain, localhost'
sudo systemctl reload postfixVerify
mydestination no longer contains the bare domain, and a new test message shows your mail provider's server as the relay in the log.
postconf mydestination
printf 'Subject: test\n\nhello\n' | sendmail info@example.com
sudo tail -n 5 /var/log/mail.logConfirmed by manpages.ubuntu.com
Cause 2 of 2
cPanel Email Routing treats the server as the local mail exchanger
You seeThe site runs on cPanel, the domain's real MX points to an outside provider, and Email Routing shows Local Mail Exchanger
Check
Mail to your own domain that disappears on a cPanel server means Email Routing is set to Local Mail Exchanger, so the server always accepts mail for the domain into its own mailboxes. Automatically Detect Configuration can land on the same choice, because cPanel's docs say it reads only the local zone file and performs no live DNS lookup.
# cPanel: Email > Email Routing, note the selected option for the domainFix
Choose Remote Mail Exchanger, which makes the server stop accepting mail for the domain and pass it to the lowest-numbered MX. If you keep automatic detection, first make the MX records in the cPanel zone match the real DNS.
# cPanel: Email > Email Routing > select the domain > Remote Mail ExchangerVerify
A form submission to an address at the domain arrives in the outside mailbox.
# send a test from the site's contact form and check the provider's inboxConfirmed by docs.cpanel.net
How do I stop it coming back?
- Set the server's host name to a subdomain such as server1.example.com when you build it, never to the bare domain.
- When you move a domain's mailboxes to an outside provider, switch cPanel Email Routing to Remote Mail Exchanger in the same change as the MX records.
- Send one test message to an address at your own domain after every mail or DNS change.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: Spotless Laundry, EZ Estimater.