Setup mail server with ldap authentication in docker
Getting an email server to run in docker is easy but getting an email server with ldap authentication to run in docker spend me a week to get up and running.
Here are the steps that I taken. I will assume you already know how to install docker.
docker run \
--restart unless-stopped \
--name openldap \
-e LDAP_ORGANISATION=domain \
-e LDAP_DOMAIN=domain.com \
-e LDAP_ADMIN_PASSWORD=complex-password \
-e LDAP_RFC2307BIS_SCHEMA=true \
-e LDAP_REMOVE_CONFIG_AFTER_SETUP=true \
-e LDAP_TLS=false \
-p 389:389 \
--volume /data/openldap/var_lib_ldap:/var/lib/ldap \
--volume /data/openldap/etc_ldap_slapd.d:/etc/ldap/slapd.d \
Install postfix-book schema into the ldap.
Install web base ldap user manager (mainly for user to change password)
Install postfix and dovecot.
Modify this line, add the reject_sender_login_mismatch at first position, to prevent user can send email as anyone.
add this line, so that user can send email not limited to own email address , user can send using alias email address.
I am trying to use AWS SES service to send outgoing email, but not sure why the postfix not able to send the correct user name and password. So I route the outgoing email to another postfix container.
Install postfix mail relay.
Install roundcube as web base mail client.
Manage email account.
This is not the perfect solution, especially the self sign cert. If you have concern with it , you can buy a cert or get a cert from letencrypt.