Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm creating a bounce email system where emails can reply to messages on my site.

However when the emails are sent to the user containing the previous message, the Reply-To field contains an email something like this (which contains the ID at the end).

If the user replies, the reply message will be sent back to which of course, doesn't have its own mailbox, except the

How would I redirect all incoming messages coming from a specific wildcard notification-message-* to I did some research, but no solid part worked, including the luser_relay = and putting notification-message-* in the postfix aliases table, the notification@ has a Maildir, so the emails would go into it.

A concept diagram:

enter image description here

I am using Ubuntu 11.04.

share|improve this question
Use pcre… – user130370 Oct 9 '12 at 2:41
up vote 2 down vote accepted

I'd be inclined to solve this using recipient_delimiter.

If you don't mind using slightly different Reply-To addresses, you can set:

recipient_delimiter = +

in your config, and then mail to e.g. (note the +) will be delivered to the notification user (assuming there are no more-specific rules/users matching notification+message-988742).

You could try setting recipient_delimiter = - (so that you could use the Reply-To headers as they are in the question) but I'm not sure how that would work with multiple instances of the delimiter on the left-hand side, and I don't have a Postfix to hand to check.

share|improve this answer

As have said mschuett, you can use regexp

First check that postfix supports regexp:

root @ mail / # postconf-m | grep regexp
root @ mail / #

Create the file /etc/postfix/aliases-regexp and add to it your regexp

root @ mail / # cat /etc/postfix/aliases-regexp
root @ mail / #

Run postmap and check whether it works:

root @ mail / # postmap /etc/postfix/aliases-regexp
root @ mail / # postmap -q regexp:/etc/postfix/aliases-regexp
root @ mail / #

If everything is OK, add this file to your alias database


root @ mail / # cat /etc/postfix/ | grep ^alias_maps
alias_maps = hash:/etc/aliases regexp:/etc/postfix/aliases-regexp
root @ mail / #

If you are using virtual domains, add this file to your virtual_alias_maps


root @ mail / # cat /etc/postfix/ | grep ^virtual_alias_maps
virtual_alias_maps = mysql:/etc/postfix/mysql/alias.conf regexp:/etc/postfix/aliases-regexp
root @ mail / #

Do not forget to restart postfix.

Good luck!

share|improve this answer
Is it possible to store the regex aliases in a database like MySQL or sqlite3, like you do with the mysql: lookup table? – rednaw Dec 17 '14 at 11:14
@rednaw Yes, definitely possible (and preferable IMO)! Just modify the query used in the file to something like query = SELECT destination FROM virtual_aliases WHERE is_regexp=0 AND source='%s' OR is_regexp=1 AND '%s' REGEXP CONCAT('^',source,'$') as described in this question. This way, you can use both regexp aliases and non-regexp aliases in the same table with a simple database flag (is_regexp). Pretty sweet. – Nick M Jan 29 '15 at 0:18

Alias maps (virtual, local, ...) will work in combination with the regexp_table format. But if you have compiled in PCRE, then you can also use the pcre_table format.

Otherwise you should search for "Postfix catch-all" which is a bit more greedy.

share|improve this answer
Do you have an example of how I can do this? – MacMac Oct 7 '12 at 14:29
Just use virtual_alias_maps with a regexp_table /notification-message-[0-9]* – mschuett Oct 8 '12 at 14:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.