When managing mailing list in Postfix with LDAP, it is required to have new alias objects created in the LDAP tree. You may need to enable attributes such as rfc822MailMember mailRoutingAddress attributes defined under nisMailAlias and inetLocalMailRecipient Object classes. These object classes are not enabled by default. You need to enable them by adding the misc.ldif
ldapadd -Q -Y EXTERNAL -H ldapi:/// -f misc.ldif
After adding the schema, you are allowed to create mailaliases in LDAP with above mentioned attributes. These attributes are used by Postfix to identify the mail recipients for a given mail address.
Below given example includes the ldif file to add staff@mycompany.com to the LDAP attribute
dn: cn=staff,ou=mailAliases,dc=mycompany,dc=com
objectClass: nisMailAlias
objectClass: inetLocalMailRecipient
objectClass: top
mailRoutingAddress: staff@mycompany.com
rfc822MailMember: chamara@mycompany.com
rfc822MailMember:ceo@mycompany.com
rfc822MailMember: ruwan@mycompany.com
After adding the staff mail aliases, postfix should configured to read the mail aliases from LDAP at main.cf
virtual_alias_maps = ldap:/etc/postfix/ldap-aliases.cf
Contents in the ldap-aliases.cf
server_host = [serverIP]
server_port = <port normally 389>
version = 3
search_base = dc=mycompany,dc=com
bind = yes
bind_dn = cn=ldapadmin,dc=mycompany,dc=com
bind_pw = <password>
scope = sub
query_filter = (mailRoutingAddress=%s)
result_attribute = rfc822MailMember
result_format = %u@%d
lookup_wildcards = no
ldapadd -Q -Y EXTERNAL -H ldapi:/// -f misc.ldif
After adding the schema, you are allowed to create mailaliases in LDAP with above mentioned attributes. These attributes are used by Postfix to identify the mail recipients for a given mail address.
Below given example includes the ldif file to add staff@mycompany.com to the LDAP attribute
dn: cn=staff,ou=mailAliases,dc=mycompany,dc=com
objectClass: nisMailAlias
objectClass: inetLocalMailRecipient
objectClass: top
mailRoutingAddress: staff@mycompany.com
rfc822MailMember: chamara@mycompany.com
rfc822MailMember:ceo@mycompany.com
rfc822MailMember: ruwan@mycompany.com
After adding the staff mail aliases, postfix should configured to read the mail aliases from LDAP at main.cf
virtual_alias_maps = ldap:/etc/postfix/ldap-aliases.cf
Contents in the ldap-aliases.cf
server_host = [serverIP]
server_port = <port normally 389>
version = 3
search_base = dc=mycompany,dc=com
bind = yes
bind_dn = cn=ldapadmin,dc=mycompany,dc=com
bind_pw = <password>
scope = sub
query_filter = (mailRoutingAddress=%s)
result_attribute = rfc822MailMember
result_format = %u@%d
lookup_wildcards = no