Postfix - Default catch-all mailbox when using SQL

When setting up a postfix + courier + postgresql mail server, I found the following SQL to be quite helpful in allowing me to have a default 'catch-all' type account for incorrectly addressed emails to go into. So in /etc/postfix/pgsql/virtual-mailbox-maps.cf plonk in something like :

query = SELECT maildir FROM mailbox WHERE username = '%s' AND active = true UNION ALL SELECT 'catch-all' || SUBSTRING('%s' FROM POSITION ('@' in '%s')) || '/' LIMIT 1;

I had initially thought of writing a stored procedure to do it, using something like Perl... but DC came up with the above, which works, so I'm happy...

Yet another post designed to help Mr Google

Technorati Tags:

Comments

Wow! A real eye-opener that

Wow!
A real eye-opener that post.
I will check your attempts with Bonzo, I'm sure he can point you in the right direction (I wouldn't waste any time with that orange dog).

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
We don't take kindly to automated nonsensible adverts around here.