On Thu, Jul 18, 2024 at 08:20:04AM -0700, Kenneth Porter via Postfix-users wrote: > On 7/18/2024 7:53 AM, Wietse Venema via Postfix-users wrote: > > - Disable the recipient_delimiter feature, and use PCRE tables for > > domain-dependent email address rewriting and routing. > > PCRE sounds promising. It can't be any harder than writing a sendmail rule! > :D You can find the sendmail rule here, which includes a regex match:
Basically, you'd need to be willing to do all routing on the bare localpart with the domain-specific extension trimmed off via a PCRE virtual_alias_maps table. But naïve implementations breaks recipient validation, so have serious drawbacks. To do it right, you need to use "pipemap" to prepare the inputs to any tables that need to support recipient delimiters. Note that some rare envelope recipient addresses could be quoted, so your rules need to consider those first: main.cf: pcre = pcre:${config_directory}/ virtual_alias_maps = pipemap:{ ${pcre}stripext.pcre, ... first virtual_alias table }, pipemap:{ ${pcre}stripext.pcre, ... second virtual_alias table }, ... canonical_maps = pipemap:{ ${pcre}stripext.pcre, ... first canonical table ... }, ... stripext.pcre: # For all domains, Strip "+" extensions, making sure an # extension is actually present! # /^"([^+]+)[+].*"@([^"]+)$/ "${1}"@${2} /^([^+]+)[+].*@([^"]+)$/ ${1}@${2} if !/@special\.example$/ # For most domains, also strip "." extensions, making sure an # extension is actually present! # /^"([^.]+)[.].*"@([^"]+)$/ "${1}"@${2} /^([^.]+)[.].*@([^"]+)$/ ${1}@${2} endif Note that local(8) does not allow PCRE tables are in alias_maps for security reasons, but since you mostly just need the pipemap tweak for recipient validation, your can define: smtpd_alias_maps = pipemap:{ ${pcre}stripext.pcre, ... first alias table ... }, ... and in master.cf add an override: smtp inet ... smtpd -o alias_maps=$smtpd_alias_maps assuming you actually have a non-empty mydestination, and actually use the local aliases(5) table. Multiple instances segregated by delimiter set are much more manageable, at the cost of an IP address per instance. -- Viktor. _______________________________________________ Postfix-users mailing list -- postfix-users@postfix.org To unsubscribe send an email to postfix-users-le...@postfix.org