2

I use email address suffixes to file emails to different folders. For example, me+suffix@example.com would be filed in folder "suffix". This works, but I would also like to allow for "-" as recipient_delimiter.

My understanding is that postfix allows for multiple separators. I can, for example, write recipient_delimiter = +-

However, this does not work together with dovecot (v.2.2.27 on my system), which allows only for a single delimiter. Therefore I can either use "+" or "-", but not both at the same time.

I now wonder whether there is a possibility in postfix to rewrite a "+" to a "-", or vice versa, before it is handled by dovecot.

user52366
  • 153
  • 7

1 Answers1

0

The canonical mapping can be used to rewrite delimiters.

# in main.cf
canonical_maps = pcre:/etc/postfix/recipient_delimiter.pcre

e.g. to remap all dashes into plus, use a regular expression like this:

# in recipient_delimiter.prcre
/^(.*)-(.*)@example\.org$/  ${1}+${2}@example.org

For single-character delimiters, such rewriting should no longer be needed, as after Dovecot version 2.3.0+ the recipient_delimiter works similar to how it works in Postfix:

The recipient_delimiter is treated as multiple one-character delimiters rather than one multi-character delimiter if more than one character is supplied. The address is split on the first character in recipient_delimiter found. -- Commit: Support multiple recipient_delimiters

anx
  • 6,875
  • 4
  • 22
  • 45