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, plus-forwarding, 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.
recipient_delimiter applies to incoming mail.
recipient_canonical_maps is essentially the same but for outgoing mail.
See Configuration below for details.
— 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, hyphen, is not often used so theoretically you could start using that one. I used to recommend that untill I had to mail someone like ‘firstname.lastname@example.org’ causing Postfix to deliver the mail to ‘email@example.com’ which belongs to someone else.
First in /etc/postfix/main.cf add or set:
# Enable address-tagging for the + character # You can append more if you need to, like: +- 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!)
When using multiple characters in ‘recipient_delimiter’ above, use this line instead:
And reload postfix
sudo service postfix reload
Note that any alias or forward 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.
2017-05-09 – Clarify the configuration parts
2017-05-05 – Minor tweaks regarding hyphen use.
2017-04-27 – Removed the part about using a hyphen for the tag, it is actually used by some folks as their email address.