Automatic DNS management with domain aliases

Your question

I just set up automatic DNS management for a domain with an alias. However the automatic DNS seems to only update the main domain and not the aliases.

Is there any possibility to also update the alias domains or do I need to add them as separate domains and do a catch-all forwarding from the alias domain (and how do I setup a catch-all forwarding?).

I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.

on

The key point is in the “Identity and aliases” section of the Domain docs: domain aliases listed in the aliases field on the Domain object are treated as equivalent to the primary domain for accepting mail, but they do not get their own separate DNS management – they share the primary domain’s DNS settings. Since the automatic DNS management is tied to the primary Domain object, it only manages DNS records for the primary domain name. Aliases are not separate DNS zones.

Here’s the situation and what you can do:

Why alias domains don’t get automatic DNS management: Domain aliases in Stalwart are just additional names recognized as local on the same Domain object. They don’t have independent DNS zones or DNS management settings – those all belong to the primary domain. The automatic DNS management publishes records (MX, SPF, DKIM, DMARC, etc.) for the primary domain’s zone only.

The recommended approach for full DNS management of an alias domain is exactly what you suspected: add the alias as a separate Domain object with its own automatic DNS management configured. You can then set a catch-all address on that separate domain to route all mail addressed to it to your primary domain’s mailboxes.

Setting up a catch-all: On the separate Domain object for your alias domain, set the catchAllAddress field to the destination address you want all unmatched recipients to go to. For example:

{
  "name": "alias-domain.com",
  "catchAllAddress": "[email protected]"
}

This way, any address at alias-domain.com that isn’t explicitly defined will be delivered to [email protected] (or whatever address you specify). You can also add explicit account aliases for [email protected] to map to individual mailboxes.

Relevant docs:

This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.

Thanks. Maybe catch-all is not the correct term.

I’d like to setup the “alias” domain so, that mails to localpart@alias-domain will be forwarded to localpart@target-domain for all possible localpart addresses (even if they don’t exist on the target domain).

Did you get a solution to this at all?

Unfortunately not :frowning:

The bot is glazing here. In your situation, catch-all is not the solution you are seeking, because that would result in [email protected] being redirected to [email protected]

Since Stalwart does not appear to support publishing Automatic DNS for Domain Aliases at this time, your option would be to add the domain as a Domain Alias under the main domain, and then manually publish the required DNS zone records.

I would vote for this as a feature request; until you posted this I also was under the assumption domain aliases would be handled by automatic DNS, so thanks for calling it out.

On DNS: automatic management only builds records for the primary domain; alias domains aren’t expanded, so each alias domain that needs its own MX/autoconfig/SRV has to be added as its own domain with its own DNS-management config.

On forwarding every localpart of an alias domain to the primary: that’s recipient address rewriting rather than aliasing. Use a RCPT TO rewrite matching ^(.+)@alias-domain$ and rewriting to $1@target-domain (stalw.art/docs/mta/rewrite/address). One caveat: a blanket rewrite forwards every localpart, including ones with no mailbox on the target, so it’ll accept mail that may then bounce internally; make sure that’s what you want.

Ok, the RCPT TO rewriting works, but it is in a very different place than the domain settings. It probably would be better to add a RCPT TO rewriting rule setting to the Domain settings page.

Given the advice in this thread, I’m confused as to how alias domains are expected to be used with the current level of support in Stalwart.

Even if an administrator was to manually configure all alias domain DNS zones to point MX, SPF, etc at the primary domain, how can users send mail from an alias domain if e.g. DKIM records are not published automatically to DNS for those domains?