How To Use Regular Expressions (regex) To Forward Email In Postfix
Create the file /etc/postfix/virtual-regexp
. For example, forward all emails with a leading eric and ending with @thewyz.net to a Gmail account:
1 |
/eric.*/@thewyz.net wyzaerd@gmail.com |
Edit the file /etc/postfix/main.cf
. Add regexp:/etc/postfix/virtual-regexp
to the virtual_alias_maps
line. For example:
1 |
virtual_alias_maps = hash:/etc/postfix/virtual, regexp:/etc/postfix/virtual-regexp |
Generate the map .db file:
1 |
postmap /etc/postfix/virtual-regexp |
This example requires the files virtual
and virtual.db
to exist, even if they are empty. If they are not present, simply create them:
1 |
touch /etc/postfix/virtual && postmap /etc/postfix/virtual |
anon said on November 23, 2020, 1:02 am:
Does this work, however, while having both virtual and virtual-regexp files working in tandem? or is it a one or the other type deal