Alias domains and DKIM

Your question

Hi.

I understood that DNS management for alias domains must be done manually.
No problem..but how does this work for DKIM?
Shall I just copy the DKIM TXTs (changing domain) also to the alias?
Does stalwart know that he has to use the key of @primary when sending from @alias?

Shall I create a DKIM for the alias? how? In Domains / DKIM Signatures I can’t create a new one for an alias. it doesn’t appear in the selector list.

How is this supposed to work?
Thanks in advance.

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

Now I understand: this is the important finding. “aliases” on the Domain object are treated as equivalent to the primary domain — they are recognized as local and do not require a separate Domain object. Let me confirm how DKIM signing works for aliased names, since dkimSignDomain returns sender_domain.

Alias domains behave differently depending on how you set them up, and that explains why DKIM Signatures won’t let you pick the alias:

If the “alias domain” is added via the aliases field on the primary Domain object (the usual way Stalwart documents domain aliasing): these names are simply recognised as additional local names for the same Domain record. They don’t get their own Domain object or id, so they can’t appear in the domainId selector when creating a DkimSignature. Mail sent from such an alias is signed automatically using the primary domain’s existing DKIM signatures; you do not create a separate key for it, and there’s nothing extra to publish in DNS for DKIM specifically (just the primary domain’s selector._domainkey.primary.com record, which should already exist). The documentation notes this is deliberate: “Administrators group alias names under the primary record rather than duplicating configuration across multiple Domains, which keeps DKIM, DNS, and TLS settings in a single place.” The signature’s d= tag will reference the primary domain’s name, not the alias, since signing resolves to the canonical Domain record.

If you instead want the alias to have its own independent DKIM identity (its own selector, its own key, its own d= matching the alias name exactly, e.g. for proper DMARC alignment when sending “as” that domain), it needs to be configured as its own full Domain object (with manual DNS management, as you’re doing), not just listed under aliases. Once it exists as its own Domain, it will show up in the DKIM Signature domainId selector and you can generate/publish a distinct DKIM TXT record for it, per Signing. The docs recommend a separate key per sending domain for exactly this reason.

So: copying the primary’s DKIM TXT record to the alias zone isn’t needed if the alias is just an aliases entry (it’s signed and validated against the primary domain). If you want the alias to sign and validate independently under its own name, create it as a separate Domain and define a DKIM signature against it.

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

Alias domains are designed for incoming mail only. Stalwart accepts mail for them as if it were addressed to the primary domain, but they have no DKIM keys of their own, which is why the alias doesn’t show up in the selector list. Anything sent from an alias address gets signed with the primary domain’s key and d= set to the primary, so it won’t align with the alias for DMARC. Copying the DKIM TXT records under the alias won’t change that, since no verifier will look them up.

If you need to send from that domain with its own DKIM signature, remove it from the aliases and create it as its own primary domain. It then gets its own keys and rotation schedule, and you publish its records like any other domain. To keep incoming mail for it landing in the same mailboxes, add a recipient rewrite rule under Settings › MTA › Session › RCPT TO Stage that maps the old alias addresses to the primary domain, for example with the condition matches(‘^(.+)@alias.example$’, rcpt) and the result $1 + ‘@primary.example’. The rewriting docs have more examples: Envelope | Stalwart