I have 2 domains, let’s say “domain1” and “domain2”. I have one account with mailbox on domain1, let’s say “user”.
I have created two aliases :
“alias” on domain1
“alias” on domain2
The result is that the alias on domain1 works as expected, whereas the alias on domain2 does not: any email to this address will not be received, and the sender will get a “Failed to deliver message” mail in return mentioning a rejected command with “code 550 (5.5.0) ‘Mailbox not found.’)”
If I modify the first alias’ local part from “alias” to “alias2”, then the second alias starts to work normally.
The conclusion seems to be that if we have 2 aliases with the same local part but with different domains, only one of them will work.
Expected Behavior
An email sent to either of the two aliases should be received in the recipient’s mailbox.
Actual Behavior
Only one of the two aliases works normally, the other fails and returns a 550 “Mailbox not found” error.
Reproduction Steps
Configure Stalwart with two domains and an account on one of them
2 Configure two aliases for this account with the same local part and both domains
3 Send an email to both aliases’ address
Stalwart Version
v0.16.x
Installation Method
Docker
Database Backend
RocksDB
Blob Storage
RocksDB
Search Engine
Internal
Directory Backend
Internal
I have reviewed the documentation and FAQ and confirm that my issue is NOT addressed there.
on
I have searched this support forum (open and closed topics) and confirm this is not a duplicate.
Let me research this issue to understand how Stalwart handles email aliases and address lookups.
Based on thorough research into the documentation and the RCPT stage lookup logic, this appears to be a bug rather than a configuration issue. Here is what the docs confirm and what this implies:
The internal directory performs recipient lookup by full email address (local-part + domain). The RCPT stage docs confirm that Stalwart “matches the RCPT address against the configured Domain objects and routes the lookup to the directoryId associated with that domain.” This means alias@domain1 and alias@domain2 should be looked up independently since they resolve to different domains.
However, your reproduction steps strongly suggest there is an indexing collision in the internal directory when two aliases share the same local part across different domains – the second alias silently overwrites or shadows the first in the address-lookup index. This is consistent with a bug in how the internal store indexes email addresses, not a misconfiguration on your part.
What you can do right now:
As a workaround, you already found that using different local parts (e.g. alias and alias2) resolves the conflict.
You could also verify whether the problem is specific to the order of creation (i.e. which alias was created first always “wins”) to help narrow down the bug.
Since the docs don’t describe this as a known limitation or expected behavior, and the RCPT lookup is documented to be domain-aware, this looks like a genuine bug that should be reported. A staff member or community contributor will be best placed to confirm whether this is a known issue in the internal directory’s address index.
This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.
The schema does support this: the unique index on EmailAlias is composite
on (name, domain_id), so two aliases with the same local part on different
domains are not supposed to collide. Something more local is going on.
Three things would pin it down. First, GET the account from the API (or stalwart-cli) and confirm both alias objects are actually persisted with
distinct domainId values; if only one is there, the WebUI patch may be
collapsing them by name. Second, hit Actions > Reload caches and re-test;
a negative-cache entry for (alias, domain2) created before the second
alias was added would behave exactly like what you’re seeing. Third, check
whether either domain has a catch-all configured, since that can mask
recipient resolution in surprising ways.
I created again the second alias and checked the account with stalwart-cli: OK
Then, I cleared the cached: OK
Finally, I tested both aliases: OK!
Since I created the second alias just as I made it yesterday, and since both domains already had a catch-all address, I think it is safe to assert that clearing the caches was the key to solve the problem.
A big thank you for your swift and efficient help!