How to use Address Tagging (user+tag@example.com) with Postfix 6


If you have an email address, then it’s almost certain that you’ve had to type it into at least one online form. And if you’re like most, you’re required to do it on a regular basis.

One way to help track whether that email address gets shared (and to be able to block mail to your email address if it gets shared with spammers) is to use an email address with an address tag instead of your regular email address.

How Address Tagging Works

Address tagging works like this:

  1. Your email address is user@example.com.
  2. Cindy’s Hula Hoop Factory asks for your email address to to process your order.
  3. You enter user+cindyhula@example.com as your email address.
  4. Any email sent to user+cindyhula@example.com automagically gets delivered to your normal email account.
  5. If you start to get SPAM at user+cindyhula@example.com, you can take any number of steps to block or filter all mail sent to that account and report Cindy as a spammer.

Configuring Postfix to Allow Address Tags

If you’re using Postfix as your mail server, telling Postfix to allow address tagging (step 5 above) is simple. Just set up a recipient delimiter by adding the following line to your /etc/postfix/main.cf file:

recipient_delimiter = +

then reload Postfix with:

postfix reload

Now, if a message comes in that is address tagged for user+tag@example.com, Postfix will then attempt to match user+tag@example.com before user@example.com in most tables, and the local delivery agent will try to match user+extension before user when looking up aliases or .forward files. So if you don’t set up any specific mappings for user+tag, then the message will simply be delivered to user.

Choosing the Right Recipient Delimiter

Most people are familiar with the plus symbol (+) as the most commonly used recipient delimiter. However, during a recent discussion on the Postfix user list, it was mentioned that some websites (particularly banks) use JavaScript to try and validate email addresses when they are entered into online forms, and that many don’t allow the plus symbol as a valid character in an email address.

They do, however, seem to prefer the minus symbol (-) so I’ve modified my recipient_delimiter parameter in /etc/postfix/main.cf to read:

recipient_delimiter = -

Then I use user-tag@example.com whenever I’m asked to provide my email address online.

Using your Address Tags

Once your recipient delimiter is set up, you can attach use any custom tag you wish to your email address to track how that email address gets used. If that tagged address gets compromised by spammers, you can then take simple steps to block that address in SpamAssassin, while still allowing mail to your regular address to come through. It’s best to use an address tag descriptive enough to let you know where you originally used it, and to use a different tag for each company or website that requests your email address.

Happy address tagging!

For more info on the recipient_delimiter parameter, you can view the official Postfix documentation for it here.

Thanks to Wietse Venema and Simon Brereton.

  • I have seen the ‘+’ in email address before and didn’t know what they were for. Thanks for the great explanation. We use gmail, and don’t seem to get much spam. I check to see if they have a ‘recipient_delimiter’ option, and do not find one. Any ideas? Perhaps we should just leave well enough alone?
    Thanks again.

  • Pingback: GMail-style address tagging med postfix och dovecot | 0x539.se()

  • I never knew about this trick. So how do i know that someone else doesn’t already actually have my username-tag? If i use it and someone registers an account using my combo wont they start getting my emails(the ones I get registered to that username+tag bit?)

    • ah kewl it works. Well I suppose we can at least rely on the uniqueness of our username and the fact that the tag can be in front OR behind username so its unknown which is the true username.

  • Could you let me know how to achieve same in Qmail?

  • “If you start to get SPAM at user+cindyhula@example.com, you can take any number of steps to block or filter all mail sent to that account and report Cindy as a spammer.”
    Except that Spammers don’t read RFCs, so they’ll ditch your “odd-looking adress” as a whole, but hey, that ends the same 😉