Is there any form to prevent local delivery on a postfix server?

Ideally, I want to avoid local delivery to some domains, because this postfix server is a google apps backup one.


In order for postfix to know not to deliver mail for a domain locally, you will need to make changes to a few (if relevant to your setup) config variables in main.cf - from the official postfix docs, you'd need to make sure you remove all domains you don't want to be treated as local from the following variables:

  • mydestination: this usually contains the list of domains delivered locally
  • local_recipient_maps: lookup table containing local recipient addresses
  • local_transport: default transport for local mail - change if inet_interfaces or proxy_interfaces match the destination of a mail
  • virtual_mailbox_domains: same as mydestination, if you're making use of it

Beyond that, I recommend you:

  • use postconf at the command line to get quick access to the current values in postfix configuration variables (man postconf for more detail)
  • visit the postconf/main.cf info page on the official postfix site for all the details

Yes, postfix can be complicated - but that's the beauty of its configurable nature.

Hope this helps!


I found this question and response by searching specifically around this issue but in the context of Plesk. It seems under som configurations (maybe dependent on your hosting provider), Plesk likes to assume postfix is going to use local delivery no matter what. Most helpful!

Then I found and followed this article which helped resolve the issue for me: http://www.rcneil.com/blog/postfix-local-loop-in-plesk/

The relevant part is:

Find your ‘main.cf’ configuration file for PostFix, which for CentOS 6, is located at /etc/postfix/main.cf ...

Then, open the file up through a text editor, or in the Linux shell, and make these lines:

virtual_mailbox_domains = $virtual_mailbox_maps, hash:/var/spool/postfix/plesk/virtual_domains
virtual_alias_maps = $virtual_maps, hash:/var/spool/postfix/plesk/virtual
virtual_mailbox_maps = hash:/var/spool/postfix/plesk/vmailbox

Commented out like this:

#virtual_mailbox_domains = $virtual_mailbox_maps, hash:/var/spool/postfix/plesk/virtual_domains
#virtual_alias_maps = $virtual_maps, hash:/var/spool/postfix/plesk/virtual`
#virtual_mailbox_maps = hash:/var/spool/postfix/plesk/vmailbox`

Then, restart the Postfix service... and voila! Your email address should be receiving those emails now.

Just wanted to record that here in case someone found it helpful to know exactly the settings that worked for me.

  • You're a life saver! thanks for leaving this answer, it has helped me to resolve my case.
    – Alyas
    Jul 28 '20 at 21:46
  • This will work if you have only one domain to receive mail for. But you won't be able to receive mails for your other domains.
    – Larsen
    Sep 24 at 12:16

I am not sure if this is the ideal solution, but I have a box with a single domain and this worked for me. I'm using Google Apps for email, and we have postfix installed to send out transactional emails, which end up going through sendgrid to be delivered to our site's users.

I found that postfix was filling up /Maildir with thousands of messages and eating up the disk space on my system.

I changed the following in etc/postfix/main.cnf:

mydestination = ip-{IP-ADDRESS-HERE}.ec2.internal, localhost.ec2.internal, , localhost


mydestination = localhost

Where {IP-ADDRESS-HERE} is your IP, e.g. 10-100-10-10

After rebooting postfix, I tested and messages are still being successfully sent to sendgrid and out via postfix, but now my maildir is no longer being filled with unnecessary messages.

  • This worked for me, March 2021 :)
    – Tim
    Mar 16 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.