Sub-addressing with Postfix

Gmail and other mail services allow users to get a nearly unlimited number of email addresses through "plus-addressing" (a.k.a. sub-addressing or address tags ): Append + and some additional characters to your username, for example john+projectname@example.org.

The mails get delivered to john@example.org, but it's now easier to filter them and to find out who is the sender (or who sold the email address to that spammer).

I wanted this for my self-hosted Postfix instance, and it turned out to be easier than I thought.

Postfix setup

In your /etc/postfix/main.cfg file, add the following line:

recipient_delimiter = +

This makes sure that Postfix splits up the email address at the +. This alone is not enough:

,
 relay=maildrop, delay=0.04, delays=0.01/0.01/0/0.02, dsn=5.1.1, status=bounced
 (user unknown. Command output: Invalid user specified. )
]]>

You'll get this when the maildrop does not know about the rewritten address and actually tries to deliver to the address with the +. To fix this, modify /etc/postfix/master.cf to use -d ${user}@${nexthop}:

I previously had -d ${recipient}, which failed.

Now reload your Postfix service and sub-addressing works.

postmap

Note: Although delivering mails works fine now, postmap will not think so:

$ postmap -q cweiske+foo@cweiske.de mysql:/etc/postfix/conf/mysql_virtual_alias_maps.cf 
$
  

No output, it did not find that email address. It seems that Postfix modifies the address already before mapping the address.

Written by Christian Weiske.

Comments? Please send an e-mail.