Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 root@example.com to user@example.com 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 user@example.com.

How do I do this?

share|improve this question

6 Answers 6

up vote 10 down vote accepted

luser_relay = user@example.com in your main.cf is what you want.

share|improve this answer
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 <myrandom@example.org>: Recipient address rejected: User unknown in local recipient table; from=<me@gmail.com> to=<myrandom@example.org></pre> –  Rory Jun 10 '09 at 23:57
    
So example.org isn't in your local recipient domains list, or something else has been misconfigured. –  womble Jun 11 '09 at 0:21
4  
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 –  Rory Jun 11 '09 at 13:50

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  user@example.com

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.

share|improve this answer

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/ you@yourdomain.com

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.

share|improve this answer

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.

share|improve this answer

To combine an answer/comment above that worked easiest for me:

luser_relay = user@example.com in your main.cf

add local_recipient_maps =

local_recipient_maps =

^ local_recipient_maps has nothing after it, and is also placed in main.cf.

share|improve this answer

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.

share|improve this answer
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. –  Rob Chanter Jul 26 '09 at 23:38

Your Answer

 
discard

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.