Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 need to setup a regex catch-all function on postfix such that:

  • tom.(anything) goes to
  • phil.(anything) goes to

How can this be achieved in postfix?

share|improve this question
up vote 10 down vote accepted

Add this to your

alias_maps = regexp:/etc/postfix/aliases

Then create /etc/postfix/aliases as follows:


See the regexp table documentation for additional information.

share|improve this answer
I setup as suggested. getting bounce as: (Action: failed, Status: 5.1.1, Diagnostic-Code: x-unix; user unknown). I checked postconf -m and saw regexp supported but still not working. bounce complain is not a real mailbox, but thats the point of alias. it should relay mail to which is elsewhere without complaining. (I use postfix with working mailman lists on ubuntu if that helps) – thevikas Nov 4 '11 at 5:04
You may need to configure virtual aliases, etc if is a virtual alias. – Flimzy Nov 4 '11 at 5:35
thanks! called it virtual_alias_maps = regexp:/etc/postfix/aliases and got it running. – thevikas Nov 4 '11 at 6:59

I don't know Postfix, but the regex you're looking for is:


Then you substitute the first matching group with nothing (empty string), and the second group with "other".

As an example, in Perl you would do:

my $regex = '^.*(\..*)@(domain).com$';

$your_string =~ /$regex/;
$aux = $2;
$your_string =~ s/$1//;
$your_string =~ s/$aux/other/;

print $your_string;

Of course this works only if email address has "domain" as domain. If you want domain to be anything, then the regex would be:

share|improve this answer

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.