We all know Gmail or Outlook and they have this great feature where you can use multiple aliasses for only one real emailaddress like username+tag@gmail.com. It is called address tagging, plus-addressing, plus-forwarding, address extension, 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 username@gmail.com
. With tagging you can use an address like username+tag@gmail.com
while your normal address remains the same.
For example, mails to username+ebay@gmail.com
are delivered to username@gmail.com
and in the inbox filters you can create a rule to move all username+ebay@gmail.com
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.
Some call this address syntax VERP because it also involves extending the recipient address. But VERP is about routing bounce messages, hence the name ‘variable envelope return path’. It is used to include the recipient address inside the Return-Path header. That way mailing lists can quickly identify who is bouncing without parsing the message. Plus-addressing, however, is only about adding a simple tag.
Postfix
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 othername+tag@forward.tld
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 remove the tag from the delivery address clearing the propagate_unmatched_extensions setting.
To clarify:
recipient_delimiter
applies to incoming mail.
propagate_unmatched_extensions
applies to outgoing mail, including internal forwarding.
See Configuration below for details.
Validating forms
Okay, so finally you set up plus tagging but then there is yet another problem: Javascript forms. You know the kind that attempts to validate the emailaddress. They quiet often refuse the +
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@isp.tld
causing Postfix to deliver the mail to firstname@isp.tld
which belongs to someone else.
Configuration (tl;dr)
Edit /etc/postfix/main.cf and 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
propagate_unmatched_extensions =
And reload postfix
sudo systemctl reload postfix
That’s all.
Note that any alias or forward matching the tagged address will override this configuration.
Note on testing: when sending mail to yourself, even using 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.
Changelog
2021-01-05 – Added note about VERP and made solution shorter. Thanks Max!
2020-04-09 – Minor readability edits
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.
Leave a Reply