For a project I started to add mailing list functionality to the development infrastructure, as requirement the mailing list should make use of the LDAP service.
In a previous article I explained that I chose OpenDJ to manage LDAP users and groups and for the management of mailing list I chose Mailman to be used with Postfix. As alternative I could have chosen Sympa but since Mailman is packaged already in many distribution and it doesn’t have many requirements like Sympa has, I preferred to go for Mailman. The drawback is that Mailman doesn’t come with LDAP support and I found a script which I adapted and uploaded on my github account.
To manage mailing list in OpenDJ you could opt for 3 ways:
- use the mailGroup object class
- use the groupOfUniqueNames object class together with the extensibleObject class
- customize your schema
OpenDJ has the schema definition of mailGroup coming from the Solaris system which allows to enter the mail of the group and the mail of the users by using the attribute mgrpRFC822MailMember.
But…most of the time you will already have your users recorded in LDAP (using most probably the inetOrgPerson) therefore, instead of directly inserting users mail you would like to insert the DN of each user, in this way even PHPLdapAdmin allows you to insert easily each user without pasting email addresses.
Therefore I went for groupOfUniqueNames which allows me to define users with their DN and, by adding the extensibleObject class, I have the possibility to add the mail attribute.
In this way if I have already defined a group I can use it as well for mailing list without replicating information (e.g. mail address for each user with mailGroup).
After that I installed and configured Mailman and, as described above, I used a perl script which:
- extracts those groups that are groupOfUniqueNames and have a mail attribute set (&(objectClass=groupOfUniqueNames)(mail=*))
- extract all the users uniqueMember belonging to the group which have an mail address set and are not disabled (&(mail=*)(!(ds-pwp-account-disabled=*)))
- creates a mailing list which will have as name the CN group attribute (saved inside the variable $listname)
If you execute the script with the command:
you will get an output like:
------------------------------ Processing list: jenkins-users-mail Found member: emidio List jenkins-users-mail does not exist. Creating new list jenkins-users-mail. Syncing jenkins-users-mail... Added : firstname.lastname@example.org ------------------------------
enjoy creating mailing lists !