What Happens If You Alias An Entire Domain in Postfix Email Server?
-
This doesn't come up often, and the issue with that is that few people know what will happen when you do this.
So the question is what actually happens if you add something like...
@myemaildomain.com [email protected]
Into Postfix's alias file? Well, it's pretty simple, but not necessarily easy to track down. This is a domain alias and from my testing, the order of precedence is not what we would expect. And that makes all of the different here.
First, we need to understand that the alias file is actions before the mailbox file (it has to be, if you think about it.) So if the alias file hijacks something in the mailbox file, the mailbox rules never get touched. That's critical because it is easy to look in your mailbox and feel that things are configured for local delivery, and with no per-user alias in the alias file, we might think that things will still go there.
Second, in the alias file the individual aliases are actioned before the domain alias. This is good, but ultimately confusing if you test an email in the domain and it works, but has an alias, it will also potentially lead you down a rabbit hole of troubleshooting that you don't want to do. So if you make an alias for an individual user, that will work normally, and only once individual account aliases are actioned is the domain alias actioned. Ultimately this makes sense as a mechanism if you think about it, but it is not really what we would expect if only approaching this casually.
So what we find is that a domain alias will not affect individual aliases, but will effectively disable all mailbox configurations for the domain in question. A powerful tool, but one you want to use carefully as the results are often not what people are thinking that they wanted to do.