Multiple domains configuration

Separate account namespaces

Given two domains, and and are different and completely independent accounts.

All changes needed to make it work is to make sure all domains are specified in the $(local_domains) macro in the main configuration file. Note that you need to pick one domain as a "primary" for use in auto-generated messages.

$(primary_domain) =
$(local_domains) = $(primary_domain)

The base configuration is done. You can create accounts using maddyctl using both domains in the name, send and receive messages and so on. Do not forget to configure corresponding SPF, DMARC and MTA-STS records as was recommended in the introduction tutorial.

Single account namespace

Lets say you want to handle messages for domains and and make that and are the same accounts. Sadly, this case is not very well-supported by maddy, but it still can be implemented.

You already should have the primary domain set for autogenerated messages and so on. The idea is to redirect all messages from non-primary domains to the primary one.

For each handled domain, the following line should be added to the modify block that gets applied for local recipients:

replace_rcpt regexp /(.+) $1@$(primary_domain)

It does regexp replacement, turning into anything@$(primary_domain) where $(primary_domain) in our case is


$(primary_domain) =

# Probably somewhere in local_routing
modify {
    replace_rcpt regexp /(.+) $1@$(primary_domain)
    replace_rcpt regexp /(.+) $1@$(primary_domain)

With that configuration, all messages for and will end up in the mailbox.

Note, however, no account credentials aliasing is done. Users should always use the account name with the primary domain to access IMAP mailboxes.

Note 1: All domains should still be listed in the $(local_domains) macro.