LDAP Email Aliases Not Working for SMTP Delivery Despite Being Visible in Admin UI #2173
-
DescriptionEmail aliases imported from LDAP are visible in the Admin UI but emails sent to these aliases are rejected with "Mailbox does not exist" error during SMTP delivery. The primary email address works correctly for authentication and is visible in the UI, but alias addresses cannot receive emails. Environment
Current ConfigurationLDAP Directory Configurationdirectory:
"ldap":
type: "ldap"
url: "ldap://openldap.openldap.svc.cluster.local:389"
base-dn: "dc=example,dc=com"
bind:
dn: "cn=admin,dc=example,dc=com"
secret: "[REDACTED]"
auth:
method: "lookup"
filter:
name: "(&(objectClass=inetOrgPerson)(|(uid=?)(mail=?))(|(employeeType=Employee)(employeeType=Contractor)(employeeType=Partner)(employeeType=Service)))"
email: "(&(objectClass=inetOrgPerson)(|(mail=?)(otherMailbox=?))(|(employeeType=Employee)(employeeType=Contractor)(employeeType=Partner)(employeeType=Service)))"
domains: "(&(objectClass=inetOrgPerson)(|(mail=*@?)(otherMailbox=*@?)))"
attributes:
name: "uid"
email: "mail"
email-alias: "otherMailbox"
secret: "userPassword"Session Configurationsession:
rcpt:
directory: "'ldap'"
relay: false
catch-all: falseLDAP User ExampleObserved Behavior
Expected BehaviorEmails sent to any of the alias addresses (defined in What I've Tried
Questions
Additional Context
Any help or guidance would be greatly appreciated. I'm happy to provide additional logs or test different configurations. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Solution Found: Root Cause and Fix for LDAP Email Alias DeliveryI've successfully resolved this issue and wanted to share the solution and root cause for anyone facing similar problems. Root CauseThe issue was that the LDAP attribute used for email aliases ( Why it appeared to work in the UIThe Admin UI correctly displayed aliases because Stalwart uses the The SolutionSince 1. Added custom schema to OpenLDAP with an indexable attribute# In OpenLDAP Helm values.yaml
customSchemaFiles:
01-mailalias.ldif: |
dn: cn=mailAlias,cn=schema,cn=config
objectClass: olcSchemaConfig
cn: mailAlias
olcAttributeTypes: ( 1.3.6.1.4.1.99999.1.1
NAME 'mailAlias'
DESC 'RFC1274: RFC822 email alias'
EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreIA5SubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )
olcObjectClasses: ( 1.3.6.1.4.1.99999.2.1
NAME 'mailAliasObject'
DESC 'Object that allows mail aliases'
SUP top AUXILIARY
MAY mailAlias )
customLdifFiles:
02-index.ldif: |
dn: olcDatabase={2}mdb,cn=config
changetype: modify
add: olcDbIndex
olcDbIndex: mailAlias eq,sub2. Updated Stalwart configuration to use the new attributedirectory:
ldap:
filter:
name: "(&(objectClass=inetOrgPerson)(|(uid=?)(mail=?))(|(employeeType=Employee)(employeeType=Contractor)))"
email: "(&(objectClass=inetOrgPerson)(|(mail=?)(mailAlias=?))(|(employeeType=Employee)(employeeType=Contractor)))"
domains: "(&(objectClass=inetOrgPerson)(|(mail=*@?)(mailAlias=*@?)))"
attributes:
email: "mail"
email-alias: "mailAlias" # Changed from otherMailbox to mailAlias3. Migrated user data to use the new attributeTesting the FixAfter implementing these changes, I verified that LDAP could now search for aliases: # This now returns the user (previously returned nothing)
ldapsearch -x -H ldap://localhost:389 -D "cn=admin,dc=example,dc=com" -W \
-b "dc=example,dc=com" "([email protected])" dn mail mailAliasAnd emails to alias addresses are now successfully delivered! Suggestions for Stalwart EnhancementWhile this solution works, it would be beneficial if Stalwart could handle non-indexed alias attributes more gracefully. Some potential improvements:
Key TakeawayThe main lesson here is that LDAP attribute visibility ≠ LDAP attribute searchability. For Stalwart's email delivery to work with aliases, the alias attribute must be properly indexed in your LDAP server. Hope this helps others facing similar issues! The combination of a custom indexed attribute and proper filter configuration completely resolved the email alias delivery problem. |
Beta Was this translation helpful? Give feedback.
Solution Found: Root Cause and Fix for LDAP Email Alias Delivery
I've successfully resolved this issue and wanted to share the solution and root cause for anyone facing similar problems.
Root Cause
The issue was that the LDAP attribute used for email aliases (
otherMailbox) was not searchable/indexable in OpenLDAP. When Stalwart performs RCPT TO validation during SMTP delivery, it uses thefilter.emailLDAP filter to search for the recipient address. SinceotherMailboxcouldn't be indexed in OpenLDAP, the LDAP search query would return no results, even though the attribute values existed and were visible when directly reading the user object.Why it appeared to work in the UI
The Admin UI …