What the message looks like
postfix/smtp[1822]: 7B2C14A0F3: to=<info@example.com>, relay=none, delay=0.1, status=bounced (mail for example.com loops back to myself)Common causes
- The MX record of the domain points to this server, but the domain is not in
mydestinationorvirtual_mailbox_domains. - A
relayhostor atransportentry sends the domain to a host name that resolves to this same machine. - The MX host name or the
relayhostresolves to an address of this server, for example after a move or a changed DNS record. - The domain sits in both
mydestinationand a virtual domain list, ormyhostnamediffers from the name in the MX.
Check
- What are the MX records of the domain?
- What do the MX hosts resolve to?
dig +short A mail.example.com - Which addresses does this server have?
ip -brief address - Routing and domain settings
postconf -n | grep -E 'myhostname|mydestination|relayhost|virtual_mailbox_domains|transport_maps'
Fix
- If this server should receive mail for the domain, add the domain to
virtual_mailbox_domains(or tomydestination), but to one list only, and define where the mailboxes are. - If another server should receive it, correct the MX record to point there, and remove the entry in
transport_mapsor therelayhostthat points back to this machine. - Make
myhostnamematch the real host name, and check that no name in the routing resolves to your own IP unless intended. - Apply with
postfix reload, then retry the stuck messages withpostqueue -f. - Send a test mail and watch
journalctl -u postfixto see the delivery.
Typical scenario
For a second domain example.org, the MX points to the existing mail server mail.example.com. Postfix, however, does not know the new domain, neither in mydestination nor in virtual_alias_domains. The log says status=bounced (mail for example.org loops back to myself). First check with postconf -n in which address class the domain belongs, and list it in exactly one of them, not in several at once.
FAQ
What is the difference to a hop count exceeded bounce?
Hop count exceeded (554 5.4.14) appears after a mail has travelled around a loop between servers. Loops back to myself is caught earlier, on the first lookup.
Does a backup MX cause this?
It can. A secondary MX that you list for a domain must be set up as a relay for it (relay_domains with a transport), or it will refuse or loop the mail.
How do I make the domain locally known?
List it in exactly one address class: mydestination for classic local delivery, virtual_alias_domains for pure forwarding or virtual_mailbox_domains for virtual mailboxes. Then postfix reload. Listing it in several classes at once causes conflicts.
Why does a look at the own interfaces help?
Postfix compares the MX's IP addresses with its own network interfaces. If the MX points to the public IP behind a NAT, Postfix does not recognize that address as local. proxy_interfaces or inet_interfaces with a matching setup help here.
Can a transport entry be the cause?
Yes. If transport_maps or relayhost for the domain points to a host that resolves back to this server, the same loop arises. Check with postmap -q example.org hash:/etc/postfix/transport which entry applies, and correct the target.