Disable Local Email Delivery With Postfix and iRedMail

You’re trying to disable local email delivery with iRedMail and postfix on your homemade email server, and you’re beating your head against the wall. You use a homemade server for email delivery, but the inbox lives on a second server. In this article, I’ll share what I’ve learned about how to disable local email delivery with Postfix and force all email for certain domains to be forward through their proper MX addresses.

I searched and searched and searched the internet for this information, and to be honest, I’m not even sure if it’s going to work for your setup. But based on the amount of time I spent researching this problem, even as a non-Linux server expert, I figured I’d pass along my findings and pray that it helps to alleviate your frustration.

The Error

If you’re seeing the “unknown user in virtual mailbox table” error, you’re in the right place. Basically, you want postfix to stop trying to deliver email to email accounts on your server that don’t exist. Is that really too much to ask?

Fixing Postfix To Disable Local Email Delivery For A Domain

postfix disable local email delivery

Basically, all of postfix’s main configuration settings are in main.cf, so you can open the file by typing vim /etc/postfix/main.cf .

Look for the virtual_mailbox_domains  line — comment it out by putting a # before it. That’s going to disable local email delivery altogether. Here’s mine:

#virtual_mailbox_domains = proxy:ldap:/etc/postfix/ldap/virtual_mailbox_domains.cf

Next, find the relay_domains  line, and prepend whatever is there with the domain names of the email addresses whose inboxes do live on your homemade email server. Mine looks like this:

relay_domains = payette.email, $mydestination, proxy:ldap:/etc/postfix/ldap/relay_domains.cf

Finally, find the transport_maps  line, and prepend hash:/etc/postfix/transport  to whatever is there. We’ll make the actual file in the next step. Mine looks like this:

transport_maps = hash:/etc/postfix/transport, proxy:ldap:/etc/postfix/ldap/transport_maps_user.cf, proxy:ldap:/etc/postfix/ldap/transport_maps_domain.cf

Now, all that’s left to do is make the transport file that says “Take all incoming email to this domain and send it through this MX server instead!”

So, create the file by typing vim /etc/postfix/transport . Add a line for each domain you want to disable local delivery for like the example below, putting the MX server inside brackets. Here’s mine:

payetteforward.com smtp:[aspmx.l.google.com]

Then, do whatever postmap does on the file by typing postmap /etc/postfix/transport . That’s important — I’d explain why, but I’m sure it’s way over your head. (I have absolutely no idea what it does.)

Trick: If you’re not sure what the correct MX server is for a given domain, you can use this groovy command to find out what it is — I think you’ll really dig it, man.

dig -tmx payetteforward.com

Next, restart postfix by typing service postfix restart , say a prayer, and then try again. If it works, buy me a Corvette. If it doesn’t, let me know in the comments section and we can work together to make this a somewhat understandable guide to fixing this problem.

Postfix Post Fix

For now, be grateful the problem is solved: You’ve disabled local delivery on your local email server running postfix or iRedMail, and you’re using the correct MX addresses instead.

About Author

I'm a former Apple employee and the founder of Payette Forward, and I'm here to help you with your iPhone.

Notify of
Inline Feedbacks
View all comments
1 year ago


6 years ago

Worked for me. Thanks a lot!

Do you know if it’s possible to add the secondary MX server for that domain? Not the local one, but the backup one of that hosting company.

7 years ago


just for info, you can define this in ldap or mysql backend without edit conf file.

// mysql per user relay
sql> USE vmail;
sql> INSERT INTO sender_relayhost (account, relayhost) VALUES (‘@domain.com’, ‘[mail.gmail.com]:25’);

// mysql per domain relay
sql> USE vmail;
sql> INSERT INTO sender_relayhost (account, relayhost) VALUES (‘[email protected]’, ‘[mail.gmail.com]:25’);

//ldap per domain relay
dn: domainName=mydomain.com,o=domains,dc=example,dc=com
senderRelayHost: [mail.gmail.com]:25

//ldap per user relay
dn: [email protected],ou=Users,domainName=mydomain.com,o=domains,dc=example,dc=com
senderRelayHost: [mail.gmail.com]:25

hope it’s help.