FIXING RECIPIENT_DELIMITER IN POSTFIX/DOVECOT/MARIADB/LDAP
2025 June 01 | CommentsFor a long while now I used a throwaway email domain where literally AnyStupidCombo@throwaway.example.com
would be delivered to my primary mailbox. That works very well for me personally, but it doesn’t scale to a mailserver of ~20 active users (ie: closest family). I never did get the + delimited version of benjamin+anystupidcombo@example.com
working on my server and sat down this morning to finally fix that.
I have a rather complex - maybe too complex - setup. I use postfix as the MTA and dovecot as the LDA, a pretty common setup these days. Somewhere in between I also do spamassassin, RBLs and more, of course, but that didn’t interfere here. A quick rundown of what each system does:
- postfix
Delivers email to other servers and accepts emails from other servers and local endusers. - dovecot
Delivers email to local users and provides IMAP access for them. - MariaDB
Holds the configuration of which email domains this server accepts emails for, and which aliases and mailboxes exist on this server. - LDAP
Authenticates endusers via emailaddress and password, and has the authoritative list of mailboxes that exist on this server. This is possible redundant with the mailbox list in MariaDB.
What I’d get if I send an email to a + email was a “User unknown” error, which makes sense. benjamin+test@example.com
really does not exist, but benjamin@example.com
does. From what I gathered from documentation and forums and email list archives around the web was that simply having recpient_delimiter=+
in my postfix main.cf should be all that’s needed. In the end, it really was.
After looking around some more I finally found THIS line in my master.cf
file of postfix:
dovecot unix - n n - - pipe flags=DRhu user=dovecot:dovecot argv=/usr/lib/dovecot/deliver -d ${recipient}
This line uses dovecot as the LDA as mentioned above. From deliver
’s man page:
-d username
Destination username. If given, the user information is looked up from userdb. Typically used with virtual users, but not necessarily with system users.
This would try to deliver an email to “benjamin+test@example.com” which doesn’t exist in LDAP, and so dovecot - correctly - raises the “User unknown” error.
More from deliver
’s man page:
-a address
Destination address (e.g. user+ext@domain). Default is the same as username.
This is the missing link I was looking for. I updated the line in master.cf
to this:
dovecot unix - n n - - pipe flags=DRhu user=dovecot:dovecot argv=/usr/lib/dovecot/deliver -d ${user}@${domain} -a ${original_recipient}
Which would now try to deliver to “benjamin@example.com” while correctly preserving the origient recipient address of “benjamin+test@example.com”
The last SEVERAL issues I had were all in master.cf - I keep forgetting that file even exists. Maybe it just needs to die.
EOF
Category: blog
Tags: postfix dovecot email selfhosting
Comments
You can use a Mastodon account to comment on this article by replying to the associated Mastodon toot.