MAKEHOSTEDDOMAINS(8)

NAME
makehosteddomains - Build a database of hosted domains

SYNOPSIS

makehosteddomains

DESCRIPTION

makehosteddomains rebuilds the contents of the @sysconfdir@/hosteddomains.dat database from the contents of @sysconfdir@/hosteddomains. This can be either a file or a directory. If it's a directory, the contents of all the files in this directory are simply concatenated. The makehosteddomains script must be run in order for any changes to @sysconfdir@/hosteddomains to take effect.

The function of @sysconfdir@/hosteddomains is very similar to the one of @sysconfdir@/locals. Both configuration files specify a list of domains that are considered to be local domains - domains whose mailboxes are stored locally.

The difference is that domains listed in @sysconfdir@/locals are removed from addresses before their mailbox is looked up. For example, if the domain "example.com" is listed in @sysconfdir@/locals, then the address <user@example.com> is delivered to a local mailbox named "user". If this domain is listed, instead, in @sysconfdir@/hosteddomains, then the address <user@example.com> is delivered to a local mailbox named "user@example.com". Usually you would use @sysconfdir@/locals to specify domains that correspond to your local system accounts, that are looked up in your system's password database. The @sysconfdir@/hosteddomains file is usually used when you have database-based virtual domains, that are maintained via an LDAP or a MySQL server. The Courier mail server's LDAP and MySQL authentication modules will use the full E-mail address to query the LDAP or MySQL server for the location of the local mailbox that correspond to the E-mail address. The Courier mail server's authuserdb authentication module can also use full E-mail addresses.

  Contents of hosteddomains

The file @sysconfdir@/hosteddomains simply contains a list of domains, one per line, for example:

    domain.com
    example.org

Each domain can optionally be followed by a single tab character, in order to specify an alias for a domain, for example:

    domain.com
    mail.domain.com<TAB>domain.com
    example.com<TAB>domain.com

First, we list the domain "domain.com" as a hosted domain. Then, we also list the domain "mail.domain.com", which is an alias for domain.com. The Courier mail server will take any address of the form <address@mail.domain.com>, rewrite it as <address@domain.com>, and attempt to deliver the mail to a local mailbox for that name. The third entry does the same for "example.com"; mail addressed to <address@example.com> is delivered to the local mailbox <address@domain.com>.

  alias@hosteddomain

This is a special local mail delivery rule for hosteddomain-listed domains. This rule allows the Courier mail server accept mail to any address@hosteddomain, where "hosteddomain" is a domain listed in the hosteddomains file, but there is no corresponding account for address@hosteddomain. To provide delivery instructions for any non-existing address in a hosteddomain-listed domain:

1) Create the local address alias@hosteddomain. For example, if the hosteddomains file contains "example.com", create the local account alias@example.com. This should be a normal account, with its own home directory, userid and groupid.

2) Create $HOME/.courier-default file in this account, containing the delivery instructions. See the dot-courier(5)[1] manual page for available delivery instructions.

NOTE that alias@example.com must be a real account, not a mail alias. If you want to forward alias@example.com to another address, put forwarding instructions in the .courier-default file. However, alias@example.com can be a clone of another account (with the same home directory, userid, and groupid).

  “WILDCARD DNS”

Wildcard DNS is supported for hosteddomains by placing a single period character before the domain name. For example, the hosted domain entry “.domain.com” will cause the Courier mail server to accept mail for “anything.domain.com”.

The Courier mail server will accept mail for <address@any.thing.domain.com> and attempt to deliver it to the local mailbox <address@any.thing.domain.com>, and if that fails then attempt to deliver the mail to the local mailbox <address@.thing.domain.com>, then finally <address@.domain.com>

    Note

    There is a period after the '@' character. If you want all mail for “any.thing.domain.com” to be delivered as though it were sent to “domain.com”, you should define an alias for the domain, for example:

        domain.com
        .domain.com<TAB>domain.com

SUBDIRECTORY CHECKS

@sysconfdir@/hosteddomains can be a subdirectory instead of a text file. This has the effect of concatenating all files in that directory (subject to the following checks) and then using the result as the @sysconfdir@/hosteddomains. The following checks are made:

    • Files whose names contain a tilde, “~” are skipped over.

    • Files whose names end with the following suffixes result in an error message: “.rpmsave”, “.rpmnew”, and “.dpkg-suffix”. These files are backup files created by package manager when updating to a newer version of the package and contain the old or the new version of a configuration file whose settings may be new or obsolete.

    The contents of the file whose name does not have the suffix should be checked against the backup. The backup file should be deleted after making any needed manual changes to the configuration file.

    • Files whose names end with the “.dist” suffix is also treated as a configuration file backup or template, but with the following exception: the “.dist” file gets ignored and automatically skipped over, without any error message, if the suffix-less file exists and its modification time is more recent than the “.dist” file's modification time.

    Otherwise an error message gets reported. Resolving the error message is done by either copying the “.dist” file or editing and saving the file without the suffix (resulting in a newer timestamp).

SEE ALSO

esmtpd(8)[2].

AUTHOR

Sam Varshavchik
    Author

NOTES

1.  dot-courier(5)
    https://www.courier-mta.org/dot-courier.html

2.  esmtpd(8)
    https://www.courier-mta.org/esmtpd.html