postfix mysql-virtual_forwardings.cf lookup removes "+" address extension
Summary
On my server I configured an email mailbox mailbox@mydomain and an email alias alias@mydomain pointing to it. I make extensive use of the address extension scheme using a + for filtering incoming mail using sieve scripts based on the extension.
In an older version of ISPconfig (3.1.13) this worked fine for both the mailbox address and the alias, but after installing a recent version of ISPconfig (3.2.12), filtering in Dovecot broke for mail aliases with an extension like this: alias+ext@mydomain.
Steps to reproduce
- set up a mailbox mailbox@domain.com
- create an alias to that mailbox alias@domain.com
- send mail to alias+ext@domain.com
- look at the log file /var/log/mail.log it contains a line like this:
2025-01-21T11:21:00.411158+01:00 myserver postfix/lmtp[145421]: 3D1DC33EA64: to=<mailbox@mydomain.com>, orig_to=<alias+ext@mydomain.com>, relay=myserver.mydomain.com[private/dovecot-lmtp], delay=0.18, delays=0.05/0.02/0/0.1, dsn=2.0.0, status=sent (250 2.0.0 <mailbox@mydomain.com> gBWAEgx1j2eiNwIAqkcjCQ Saved)
Dovecot sees the mail envelope without the address extension so sieve scrips filtering based on envelope :detail don't work.
Correct behaviour
Instead the log line should be like this:
2025-01-21T11:20:24.790199+01:00 myserver postfix/lmtp[145313]: 90D4533EA38: to=<mailbox+ext@mydomain.com>, orig_to=<alias+ext@mydomain.com>, relay=myserver.mydomain.com[private/dovecot-lmtp], delay=0.21, delays=0.06/0.02/0.03/0.11, dsn=2.0.0, status=sent (250 2.0.0 <mailbox+ext@mydomain.com> 0MNSKOh0j2eiNwIAqkcjCQ Saved)
Environment
- Debian 12
- ISPConfig version: 3.2.12p1
- Postfix version: 3.7.11
Proposed fix
I don't have a fix ready, but reverting the mysql-virtual_forwardings.cf to the state it was in earlier ISPconfig version fixes this problem, but I am not sure which features get broken. This seems to work instead of the explicit SQL query:
[...]
table = mail_forwarding
select_field = destination
where_field = source
additional_conditions = and active = 'y' and server_id = 1
To debug the issue it is helpful to add a -v parameter to the cleanup process in master.cf