Stopping local mail delivery for virtual server

I set up a virtual server in the usual way - email, web site etc. But subsequently the domain owner decided to use Gmail external mail servers (MX records set for Gmail).

However if another virtual server on the box tries to send an email to this domain, it seems to me that it tries to deliver locally, and that fails (I have now switched off mail for that domain of course).

In fact if I try this:
telnet 25

I get:
Trying [my box IP address]…
Connected to
Escape character is ‘^]’.
220 ESMTP Postfix

I should of course get a connection to the Gmail servers.

a) How can I fix this?
b) Is there a way to set up a template for such domains so they work “out of the box”?

(BTW, my box is not running BIND. The domains’ DNS is set up externally)



It sounds like you want to disable the Virtual Server’s Mail for Domain feature.

You can do that by going into Edit Virtual Server -> Enabled Features.

That will prevent Postfix from trying to deliver email locally for this Virtual Server.



I’ve gone in and disabled that feature - but no better. I’ve also restarted Postfix.

I notice that if I go to Webmin-> Postfix I can still see entries for the domain in “virtual domains” and “user mailboxes”. (I’m reluctant to fiddle with the Postfix settings there and just delete these!)

More crucially - if, as I say, I try to connect to the domain’s mail server from the command line, it’s clear that DNS lookup is being skipped as Postfix thinks the domain is local.

I think my problem is: “How can I persuade Postfix to do DNS lookup for this domain?”. Which perhaps comes down to: “Where does Postfix get the idea it should NOT do DNS lookup for this domain?”


Postfix won’t do DNS lookups for any domain it thinks is locally hosted.

We’ve seen some occasions where a few stray entries remained even though Mail for Domain was disabled.

My suggestion would be to log into your server over SSH, and to edit “/etc/postfix/virtual”.

From there, remove any references you see to the domain that should be removed, as well as the accounts in it.

Once you’re done, save the file, and run “postmap /etc/postfix/virtual”.

Then, see if email works for you at that point.



The domain is no longer referenced in /etc/postfix/virtual and I ran “postmap /etc/postfix/virtual”

Also, I created a new account plan with all email options disabled and applied that to the virtual server.

But unfortunately, Postfix still thinks the domain is local!

I notice that the domain still has an entry under postfix >> user mailboxes. Perhaps I need to get rid of that. But how?

One other place you may want to look – do you see any references to that domain in /etc/postfix/

If it were listed on the “mydestination” line, for example, that could cause trouble.


No, nothing there I’m afraid Eric.

One thing I notice - even though I think I have created a hosting plan with all email disabled, when I create a new server from that plan, Virtualmin STILL creates a mail user:

“Creating mailbox for administration user …”

If I then look at Postfix users, sure enough there’s the new guy.

But this must mean that Postfix will think the domain is local?

But this must mean that Postfix will think the domain is local?

No, it shouldn’t mean that… I suspect that’s just creating the Maildir directory.

If there’s no entry in /etc/postfix/ or /etc/postfix/virtual – Postfix in theory shouldn’t consider the domain to be local.

You could always try doing a search on the other files in /etc/postfix/ to make sure none of them mention your domain, but by default they shouldn’t.

Also, you may want to double-check that the DNS on your server thinks the email is hosted elsewhere.

Try running the command “host -t MX your_domain_name.tld” – does that show the proper MX record?


Thx again Eric.

Yes, “host -t MX your_domain_name.tld” reports correctly.

I can find no reference to the domain in the Postfix directory. However there is a binary database called “virtual.db” that I can’t read easily. Could that be the source of the trouble?

If you type this command:

grep YOUR_DOMAIN.TLD /etc/postfix/*

That should show you if your domain exists in any file there, including the binary files such as virtual.db.

Whenever you ran “postmap /etc/postfix/virtual”, that should have re-created that virtual.db file with your changes.

It really sounds like you’ve done everything right – can you show the mail log entries that show up whenever you try to send an email from your server to this particular domain?


:wink: It seems to be working now!

I don’t know what I’ve done to fix it. (Probably the original changes in this discussion).

The thing that’s thrown me off the scent is that I have been doing this and expecting to talk to the Google mail server:

telnet problem-domain.tld 25

But the connection I get is to the local postfix server:

Trying [local ‘A’ record IP address, NOT the correct MX address]
Connected to problem-domain.tld
Escape character is ‘^]’.
220 my-server-box.tld ESMTP Postfix

But when I completed the telnet transaction, checked the server logs, I saw the mail delivered to Google.

So thanks very much Eric. All seems to be well now.