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 email@example.com
- all emails sent to anythingelse@thesedomains (catch-all) are forwarded to firstname.lastname@example.org.
When I test this file with postmap, everything is ok :
# postmap -q email@example.com regexp:/etc/postfix/virtua
# postmap -q firstname.lastname@example.org regexp:/etc/postfix/virtua
However, when I apply the config, and send a test email to email@example.com, the mail is sent to firstname.lastname@example.org 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 ?