OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Catch-all in virtual alias table : BUG ?

From: Benjamin Morel (benjamin.morelgmail.com)
Date: Sun Feb 10 2008 - 21:26:52 CST


Hi,

I'm setting up a postfix server with virtual alias table to redirect my
emails based on regexp rules.

 

I set this line in /etc/postfix/main.cf :

virtual_alias_maps = regexp:/etc/postfix/virtual

 

Here is my /etc/postfix/virtual :

 

# BEGIN SNIPPET

 

^domain1\.com DOMAIN

^domain2\.com DOMAIN

 

/^tech/ email1otherdomain.com

// email2otherdomain.com

 

# END SNIPPET

 

My goal is to have a list of domains, where :

- all emails sent to techthesedomains are forwarded to
email1otherdomain.com

- all emails sent to anythingelsethesedomains (catch-all) are forwarded to
email2otherdomain.com.

 

When I test this file with postmap, everything is ok :

# postmap -q techdomain1.com regexp:/etc/postfix/virtual

email1otherdomain.com

# postmap -q anythingdomain1.com regexp:/etc/postfix/virtual

email2otherdomain.com

 

However, when I apply the config, and send a test email to techdomain1.com,
the mail is sent to email2otherdomain.com instead.

The log file /var/log/maillog show this :

 XXXXXXXXXXXX: to=<email2otherdomain.com>, orig_to=<techdomain1.com>,
relay=...

 

If I remove the last line of the /etc/postfix/virtual, the mails to
techdomains are sent to their correct destination.

 

According to the manual :

"Patterns are applied in the order as specified in the table, until a
pattern is found that matches the search string".

So the first matching pattern, and not the second one, should be used (as
postmap correctly does).

 

Any idea why ?

 

Thanks.

Ben