Chapter 12. Virtual Domains

In qmail-speak, a virtual domain is one handled locally but with a different set of mailboxes from the home domain. Qmail’s virtual domain handling is one of its strongest features, thanks to a simple and clean design.

How Virtual Domains Work

Qmail turns addresses in a virtual domain into subaddresses of a local user, then handles the subaddressed message like any other local message. The translation from virtual to local addresses is in the control file virtualdomains. Assume, for example, that it contained the line:

myvirt.com:virtuser

Then mail addressed to marvin@myvirt.com is translated to virtuser-marvin, and then delivered normally. If there’s a user virtuser, it checks for ~virtuser/.qmail-marvin or ~virtuser/.qmail-default. If there’s no such user (which is often the case), the address is turned into alias-virtuser-marvin and delivered under the control of ~alias/.qmail-virtuser-marvin or ~alias/.qmail-virtuser-default or ~alias/.qmail-default.

When qmail translates the mailbox part of a virtual domain address, it does not change the domain. That is, in the previous example, marvin@myvirt.com is translated to virtuser-marvin@myvirt.com. This seems like a mistake, because this is not Marvin’s address, until you realize that the translated address is used only within qmail. The virtual domain remains with the address throughout the delivery process, so delivery programs can check $HOST or $RECIPIENT to tell whether a message was addressed to a virtual ...

Get qmail now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.