Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 03-03-2009, 09:57 AM   #1
LQ Newbie
Registered: Jun 2008
Location: Västerås, Sweden
Distribution: Arch Linux, Debian, Ubuntu
Posts: 21

Rep: Reputation: 16
Question Postfix catch-all alias problem (using mysql)

Hi all!

I am having a bit of problems with catch-all alias in postfix.
Today I finally got my postfix/dovecot setup working, using authentication via mysql.
But then I got into a problem, with catch-all alias.

In the database in my alias table I added:

The problem is that the alias is loaded before the regular adresses, so if someone tries to mail to the mail is delivered to
While logging the mysql queries I can see that because it first looks at the aliases in many different ways and because it gets a result with it accepts that.

Does anyone have any idea on how to either modify the query or modify postfix to read the aliases after the adresses?
Old 07-06-2009, 03:06 PM   #2
LQ Newbie
Registered: Jul 2009
Posts: 1

Rep: Reputation: 0
Good morning

Did you arrived to repaired that ?

Because I am facing the same problem
Old 04-13-2010, 01:24 PM   #3
LQ Newbie
Registered: Apr 2010
Posts: 1

Rep: Reputation: 0
Answer to Postfix virtual alias catch-all problem


I know this thread is quite outdated, but it still appears on search results. I came up with a solution to this problem a few years ago, but was searching to see if anyone came up with a different approach, or if the How-To was updated.

The problem can be duplicated as follows:

* Postfix is set up to use virtual_alias_maps. An example would be as follows in the configuration file:
virtual_alias_maps = mysql:/etc/postfix/
* The file may be configured as follows:
table = virtual
select_field = dest
where_field = alias
additional_conditions = and status = '1' order by alias desc
* The domain is added.

* An account user is created. For example:

* An account is added that will be used as a catch-all. For example:

* An alias is added as a catch-all account. For example, is aliased to

* Now, when mail is sent to, it should be sent to However, it will end up in Thus, the problem arises.

The reason this happens is because Postfix first checks the virtual_alias_maps for an alias. matches as an alias. No other aliases exist. Therefore, the mail is sent to the catch-all account.

There are two possible solutions. The first would be to create an alias for each and every account. For example, your alias table would contain an alias of, with a destination of This is inconvenient if you are using software such as Web-Cyradm to administer your accounts. You cannot tell Web-Cyradm to add this alias for every account without hacking Web-Cyradm.

The better solution would be to update your virtual_alias_maps file, in my case, to search the table holding your virtual e-mail account users. The change can be applied as follows:

Edit the virtual_alias_maps directive in configuration file as follows:
virtual_alias_maps = mysql:/etc/postfix/, mysql:/etc/postfix/
Now, create the file /etc/postfix/ with the following:
table = accountuser
select_field = username
where_field = username
additional_conditions = and status = '1' order by alias desc
Now, when an e-mail is sent to, two matches are found. The returns, which is aliased to The returns, which is aliased to Since is the more specific of the two results, mail is delivered to this address, instead of the catch-all.

Be sure to reload the postfix configuration files before testing.

If you are more curious about the inner workings of this. You can turn on mysql logging and view the queries made both before and after the change. You will see what queries are made.

Please note that you may have to change the mysql-*.cf configuration files to correspond with your table structure. The tables I am using are the default tables used by Web-Cyradm.

If anyone has a better solution, please respond on here. I've used this method for several years without a problem. If you have any questions, please ask.



alias, catchall, domain, mysql, postfix

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Postfix alias table problem.. unifiedquarks Linux - Server 2 08-09-2008 01:03 AM
Postfix Configuration Question: Postfix server as a catch-all on office LAN enso491 Linux - Server 5 04-14-2008 04:35 PM
Postfix Alias Problem irishred Linux - Server 3 01-16-2007 02:12 PM
Postfix local catch-all alias cdhgee Linux - Software 2 06-30-2006 03:02 AM
Mysql - Postfix alias domain paulten Linux - Networking 0 11-03-2003 04:05 PM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:35 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration