Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Email delivery

Mail from your web server to addresses at your own domain never reaches the real mailbox

Your error

User unknown in local recipient table1 more line it can show

Fix it fast

Most common cause, 1 of 2

Postfix 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.

Fix
sudo postconf 'myhostname=server1.example.com'
sudo postconf 'mydestination=$myhostname, localhost.$mydomain, localhost'
sudo systemctl reload postfix
Did this fix it?
Full steps for this cause: check, fix, verify

Short 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.

  • Applies to Postfix 3.8, Ubuntu 24.04, cPanel and WHM Email Routing
  • Updated
  • By Maaz Zindani, Senior Software Engineer

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.

Run this first
postconf myhostname mydomain mydestination
hostname -f
sudo grep "to=<info@example.com>" /var/log/mail.log | tail -n 5

Then find the line you see in this list and open its fix:

  1. 1Postfix lists your domain in mydestinationpostconf shows example.com in mydestination, usually because myhostname is the bare domain or $mydomain was added to the list
  2. 2cPanel Email Routing treats the server as the local mail exchangerThe 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 table
  • PHP 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.

Check
postconf myhostname mydestination

Fix

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.

Fix
sudo postconf 'myhostname=server1.example.com'
sudo postconf 'mydestination=$myhostname, localhost.$mydomain, localhost'
sudo systemctl reload postfix

Verify

mydestination no longer contains the bare domain, and a new test message shows your mail provider's server as the relay in the log.

Verify
postconf mydestination
printf 'Subject: test\n\nhello\n' | sendmail info@example.com
sudo tail -n 5 /var/log/mail.log

Confirmed by manpages.ubuntu.com

Did this fix it?

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.

Check
# cPanel: Email > Email Routing, note the selected option for the domain

Fix

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.

Fix
# cPanel: Email > Email Routing > select the domain > Remote Mail Exchanger

Verify

A form submission to an address at the domain arrives in the outside mailbox.

Verify
# send a test from the site's contact form and check the provider's inbox

Confirmed by docs.cpanel.net

Did this fix it?

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.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.