///Mail Address Tags With Zarafa

Mail Address Tags With Zarafa

2017-11-15T14:30:46+00:00Autor: Daniel Morlock

Mail Address Tags or Mail Address Extensions are meant to allow a user to extend his or her email address. The user can add a tag (or extension) to his address and will still recive mail in his standard inbox. Lets make an example: the email address of Robert may be robert.paulson@example.com. Using address tags, Robert can add the name of the page where he has registered himself with his mail address, for example robert.paulson+twitter@example.com. The seperation with a plus sign is not a must, but it is the common use. In fact you could use any valid email string to indicate mail tags. When Robert now recives an email with such a tag, he can easily create a filter rule for example to move all tagged emails to a specific folder.

Zarafa does not support address tags at the moment. But when running zarafa with postfix it is possible to use the flexibility of postfix to accomplish email tag support with zarafa.

Postfix Setup

First of all, we need to tell postfix that we use address extensions. So open /etc/postfix/main.cf and add or uncomment the line

recipient_delimiter = +

That is all that is needed to configure postfix to use address extensions. It will automatically use it in aliases, virtual users, etc.

The Magic: Regexp Alias Map

An easy way to work around Zarafa’s lack of address extension is to rewrite the mail address by just removing the tag. This will send the mail to the correct inbox but the user can’t create filters that use the address tag, because it was removed. A better way is to use an alias map based on regular expressions: For doing so, create the file /etc/postfix/address_extension and add the following regular expression:

/([^+]+)\+.*@(.+)/    $1@$2

A brief explaination of the expression:

  • [^+]+ matches all symbols but the plus sign and at least one of them
  • \+ matches the actual delimiter of the mail address; note that the + is escaped by a back slash
  • the followed .* matches any number of any symbols (also nothing at all to allow name+@example.com)
  • the @ is the actual @ in the mail address
  • which means the last part is the domain of the mail address
  • standard brakets () surround strings that can be accessed on the rewrite side (e.g. $1 matches the string inside the first brakets)

Postfix expects the file to be in a database format. To create this database, run the following command:

# postmap /etc/postfix/address_extension

The last step is to add the alias map to your postfix setup:

virtual_alias_maps = <other alias maps> regexp:/etc/postfix/address_extension

If you encounter problems or on questions, do not hesitate to contact us.