Last updated: Mon 27 Apr 1998

Virtual hosts with qmail

Virtuals hosts are quite easy to set up using qmail, and once set up, they allow normal users (ie. not just the superuser) to manage the virtual host.

Virtual hosts are specified in the virtualdomains file, usually found in /var/qmail/control. This file has the format:

  full_virtual_host_address:local_user

Handling virtual host mail as a local user

As an example, you have a machine called bedrock.stoneage.com, and you want to handle mail for the virtual domain flintstone.stoneage.com. You decide to create a user, flintstone, to handle mail for this virtual domain. The virtualdomains file on bedrock.stoneage.com would contain the following entry:
    flintstone.stoneage.com:flintstone
Now, all mail sent to user@flintstone.stoneage.com gets remapped to flintstone-user@bedrock.stoneage.com . For example, if mail gets sent to:
  pebbles@flintstone.stoneage.com
mail gets delivered to:
  flintstone-pebbles@bedrock.stoneage.com
Since the user flintstone on bedrock.stoneage.com controls all mail to flintstone-anything, this user effectively controls all email addresses in the flintstone.bedrock.com domain.

For example, mail to:

  pebbles@flintstone.stoneage.com
would be controlled by ~flintstone/.qmail-pebbles.

Using the alias user

If you don't want to create a new user to handle a virtual domain's mail, you can use the alias user, which is created when you install qmail, to handle it instead.

Again, you have a machine called bedrock.stoneage.com, and you want to want to handle mail for the virtual domain flintstone.stoneage.com. You decide to let the alias user handle the mail. In the virtualdomains file on bedrock.stoneage.com put:

  flintstone.stoneage.com:alias-flintstone
Now, all mail sent to user@flintstone.stoneage.com gets remapped to alias-flintstone-user@bedrock.stoneage.com. This means that all mail to the flintstone.stoneage.com domain is controlled by the ~alias/.qmail-flintstone-* files on bedrock.stoneage.com.

For example, mail to:

  pebbles@flintstone.stoneage.com
would be controlled by ~alias/.qmail-flintstone-pebbles.

Additional notes

You also need to add flintstone.stoneage.com to the rcpthosts file (usually in /var/qmail/control) on bedrock.stoneage.com, so that bedrock.stoneage.com will receive mail for flintstone.stoneage.com.

The MX record for flintstone.stoneage.com should point to bedrock.stoneage.com.

See the dot-qmail man page for information on creating .qmail files.


Acknowledgements

Russell Nelson
Information on using the alias user.

Keith Burdis <keith@rucus.ru.ac.za>