We all know Gmail or Outlook and they have this great feature where you can use multiple aliasses for only one real emailaddress like email@example.com. It is called address tagging, plus-addressing, sub-addressing or even sub-aliassing, and existed way before these services came around. This method allows you to ‘tag’ the sender of the mails and apply custom filtering. Also it allows you to see if they are sharing your emailaddress with other parties.
How it works
Normally you have an address like firstname.lastname@example.org. With tagging you can use addresses like email@example.com while your normal address remains the same. For example, mails to firstname.lastname@example.org are delivered to email@example.com and in the inbox filters you can create a rule to move all firstname.lastname@example.org mails to another folder.
For mail services like Gmail and Outlook.com it works out of the box. When you run your own mailserver, especially Postfix, you may first need to enable this feature.
To enable this behaviour in Postfix you only have to set the recipient_delimiter in
main.cf and reload the daemon, but there is a catch. For some reason unknown to mankind Postfix is appending the inbound ‘tag’ to the forward email address, so that becomes email@example.com causing problems with delivery. Postfix attempts to tell the mailserver at ‘forward.tld’ in the SMTP
RCPT TO command it has mail for the ‘othername+tag’ user, which doesn’t exist since it should be only ‘othername’. You need to rewrite the delivery address using recipient_canonical_maps.
— Validating forms
+ sign because it is not a so called word-character in the regular expression matching they perform. Those often only include A to Z, 0 to 9, period, underscore and hyphen. The last one, hypen, is not very common in emailaddresses so you can use the
- too in your address tagging configuration.
First in /etc/postfix/main.cf add or set:
# Enable address-tagging for + and - characters recipient_delimiter = +- # Remove the tag from the forward address recipient_canonical_maps = regexp:/etc/postfix/recipient_canonical_maps
Now add this to /etc/postfix/recipient_canonical_maps (one line!)
And reload postfix
sudo service postfix reload
Note that any alias or forward configured matching the tagged address will override this configuration.
A sidenote on testing: when sending mail to yourself, even via forwarders, Gmail will accept the mail but won’t deliver it to your inbox. That is because it is counted as a duplicate. Better test from another account.