Mail forwarding with Postfix and LDAP

September 02, 2017

Reading time ~1 minute

For the most part mail forwarding is not too common within my Infrastructure. With Sieve deployed in my environment using the ManageSieve protocol - mail users are able to easily setup a redirect to their preferred email address. This all works fine, but I also wanted to have the ability to setup mail forwarding directly within OpenLDAP.

Today I went ahead and pushed a commit for postfix-book.schema to include a mailForwardingAddress attribute. The existing PostfixBookMailForward objectClass contains our mailForwardingAddress attribute, respectively.


Assuming the schema is loaded into your environment, we can now tell Postfix to use LDAP mail forwarding.


We can create in /etc/postfix/ldap with something like

server_host = ldap://
search_base = ou=Mail,dc=example,dc=com
version = 3
bind = no
query_filter = (&(|(mailAlias=%s)(mail=%s))(objectClass=PostfixBookMailForward))
result_attribute = mailForwardingAddress

The query_filter will match a user's primary mail address or any mail aliases while the result_attribute is the forwarded email address.

The file should have the file defined in virtual_alias_maps using proxy:ldap:/etc/postfix/ldap/

virtual_alias_maps = ldap:/etc/postfix/ldap/,ldap:/etc/postfix/ldap/ proxy:ldap:/etc/postfix/ldap/

To verify mail forwarding we can see that our forwarded email address does get returned when querying the primary or alias email address.

postmap -q ldap:/etc/postfix/ldap/
comments powered by Disqus

Arch Linux Email Beta Project

Intro I started this small project a while back for my own use and over the course of several years the Infrastructure I had planned came to…… Continue reading

Increase email security with S/MIME

Published on September 03, 2017

Creating LDAP mail users and groups

Published on September 01, 2017