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/virtua
My /etc/postfix/virtual is in the code snippet below.
My goal is to have a list of domains, where :
- all emails sent to tech@thesedomains are forwarded to firstname.lastname@example.org
- all emails sent to anythingelse@thesedomains (catch-all) are forwarded to email@example.com.
When I test this file with postmap, everything is ok :
# postmap -q firstname.lastname@example.org regexp:/etc/postfix/virtua
# postmap -q email@example.com regexp:/etc/postfix/virtua
However, when I apply the config, and send a test email to firstname.lastname@example.org, the mail is sent to email@example.com instead.
The log file /var/log/maillog show this :
If I remove the last line of the /etc/postfix/virtual, the mails to tech@domains 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 ?