15

I have a server with two domains. I get the warning as mentioned in the title:

do not list domain example.com in BOTH mydestination and virtual_alias

Although I receive the above warning, it works just fine without problems. But I want to know how to fix it.

The reason for having the domain in both places is because I want to implement catchall - all email sent to @domain.tld should go to the mail account of that domain.

Now, if I don't put the domain in mydestination, the server refuses to accept email for that domain because it does not want to be an open relay. If I don't put the catchall alias into the virtual alias table, the catchall doesn't work (obviously).

So what is the correct solution? I have tried to read the stuff on http://www.postfix.org/VIRTUAL_README.html#virtual_alias, but I just can't seem to make my setup work any other way.

(PS: I am using webmin/virtualmin to manage my website, and when I try to configure it with the built-in configuration tools it comes up with the same solution I have manually. So it seems even webmin doesn't know a better way to do this...)

cornergraf
  • 481
  • 1
  • 4
  • 8

4 Answers4

10

The default for mydestination is:

$myhostname, localhost.$mydomain, localhost

Try setting it to

localhost.$mydomain, localhost

instead. I had a similar warning, and making this change doesn't impact mail delivery on my server for the domain in question. If you're still having problems, you should probably post your main.cf and virtual_alias settings.

jetboy
  • 882
  • 2
  • 11
  • 25
  • OH that's right! I had $myhostname set to my domain, so it appeared twice! No wonder I couldn't grep for it! – Chloe Jan 07 '17 at 06:31
6

You don't need the domain listed in in virtual_alias_domains for it to be looked up in the virtual_alias_map.

From the virtual(5) man page:

The optional virtual(5) alias table rewrites recipient addresses for all local, all virtual, and all remote mail destinations. [emphasis added]

virtual_alias_domains is a list of domains that addresses MUST be looked up and found in the virtual alias map.

Craig
  • 591
  • 2
  • 5
3

My solution was the following:

  • Remove example.com from mydestination
  • Replace the virtual alias mainuser@example.com to mainuser with an alias to localmailbox@localhostname (localhostname being anything in mydestination)

What I learned was that Virtualmin creates so called "virtual alias domains" by specifying the domain name in the virtual alias tables. Postfix documentation states that in this case local mailboxes can't be a (direct) target.

Tarnschaf
  • 295
  • 3
  • 16
  • 1
    After HOURS of bumping my head to the wall, the solution is this! When I changed the "username' to "username@localhost" everything worked! – Panayotis Aug 25 '22 at 20:41
0

I changed this on a busy Virtualmin Ubuntu 20.04 mail server, I did:

Before:

mydestination = $myhostname, localhost.our-main-domain.com, , localhost

After:

mydestination = localhost.our-main-domain.com, , localhost

This caused a catastrophic failure as ever message started to bounce. For now I'm going to have to live with the warning, although it's truly annoying when doing complex troubleshooting.

This whole issue is really confusing because actually on my system I don't even find anything virtual_alias_domains but rather something called virtual a file on the disk which appears to have this 'alias'.