I'm using postfix for my email. I know I can use /etc/aliases and newaliases command to redirect certain email, eg I can redirect [email protected] to [email protected] by putting root: user in my /etc/aliases and then running newaliases. However I'd like to do the equivilant of *: user, so that all email to example.com will get sent to [email protected].

How do I do this?

7 Answers 7


luser_relay = [email protected] in your main.cf is what you want.

To disable user checking and accept all mails you need to add the local_recipient_maps = option. Documentation

  • 1
    I added that to main.cf and restarted postfix. I got the following error in /var/log/main.info: <pre>550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in local recipient table; from=<[email protected]> to=<[email protected]></pre> Jun 10, 2009 at 23:57
  • So example.org isn't in your local recipient domains list, or something else has been misconfigured.
    – womble
    Jun 11, 2009 at 0:21
  • 7
    I got it working. Aswell as the luser_relay option you mentioned you also need to add "local_recipient_maps =" option. This postfix documention page explains that: postfix.org/postconf.5.html#luser_relay Jun 11, 2009 at 13:50
  • Does this method preserve the To email address? (the virtual maps rewrites it and the original To: address is lost.)
    – user14645
    Jul 6, 2015 at 19:51
  • 1
    @Sverre questions are for questions, not comments on seven-year-old answers to tangentially-related questions.
    – womble
    Apr 4, 2016 at 2:14

What you are looking for is a virtual alias table and can be done using the following...

First you need to edit, or create if it doesn't already exist, the /etc/postfix/virtual file.

example.com   whatever
@example.com  [email protected]

After this has been saved you will need to run postmap /etc/postfix/virtual in order to generate the indexed /etc/postfix/virtual.db Postfix will read.

You will then need to edit the /etc/postfix/main.cf and be sure that you have the following line uncommented:

virtual_alias_maps = hash:/etc/postfix/virtual

This will actually let postfix know about the virtual alias table and use it.

The problem with using the luser_relay option as others have mentioned is that this is treated as the user of last resorts for unknown addresses by the local delivery agent. If postfix is only handling mail for one domain this can be utilized for this but it can mask other configuration errors and will likely cause unexpected results if more than one domain is being handled.

The one caveat I feel obligated to mention is that by creating a wildcard alias of this nature you are opening up your mail system to accept messages for addresses that will not exist and run the risk of having the mailbox filled quickly with spam for non-existent mailboxes.


It's actually quite simple. All you need to do is to put something like this in your main.cf file:

virtual_alias_maps = regexp:/etc/postfix/virtual_alias

The regexp part does the trick. Also, in /etc/postfix/virtual_alias you put something like this:

/^test/ [email protected]

In this example you should receive all mail with destination starting with 'test'. Don't forget to postmap /etc/postfix/virtual_alias and reload postfix.


To combine an answer/comment above that worked easiest for me (I have one primary domain):
Add the following to /etc/postfix/main.cf :

luser_relay = [email protected] (or local system user)
local_recipient_maps =

(local_recipient_maps = has no value set)

I use a local user linux account and also add same user to /etc/aliases so that user gets all mail to root,postmaster,etc.

Note: luser_relay works only for the Postfix local(8) delivery agent.

For virtuals, you can use virtual_alias_maps and point any virtual domain addresses/catchalls at your main email account.

Please consult luser_relay or virtual_alias_maps for more info.


If you want to use a catch-all address for mydomain, you can use /etc/aliases combined with a regex as follows:

In /etc/postfix/main.cf add
alias_maps = hash:/etc/aliases, regexp:/etc/postfix/catch-all-local.regexp

In /etc/postfix/catch-all-local.regexp add
!/^owner-/ your-catch-all-user

This should do the trick. It worked for me, and works with virtual_alias_maps set in parallel.


There is a less known static lookup table type in Postfix, which can be used for exactly this purpose:

alias_database = static:[email protected]
alias_maps = static:[email protected]

If [email protected] is not local for this system, you'd also probably want to discard all the bounce messages by replacing lines ending with bounce with discard in master.cf to avoid the mail loops.


I hate to be a killjoy, but your problem is that you're using Postfix. Postfix makes precisely this exercise very difficult. I know: I had to do it some years ago and it took days and days to get it right. The luser option is the right one, but there are other things to get right, too. (And even the name of the option shows that Postfix's authors didn't really want to support this.)

I recommend switching to Courier. Courier supports this "catch-all" method in a much more sensible way because of the way it extends its existing alias system.

  • 1
    Postfix doesn't make it difficult at all. Virtual aliases are the standard way to do catchalls in Postfix and they're very easy. That said, on anything but a toy mail server for your own personal domain, catchalls are a very bad idea. Jul 26, 2009 at 23:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .