Skip to content

Instantly share code, notes, and snippets.

@BorysVrublevskyi
Last active November 22, 2023 14:23
Show Gist options
  • Save BorysVrublevskyi/3fc31ad00cf009be0c6fd3d776b98dd3 to your computer and use it in GitHub Desktop.
Save BorysVrublevskyi/3fc31ad00cf009be0c6fd3d776b98dd3 to your computer and use it in GitHub Desktop.
MailCow Postfix regex catch mail redirect

This will allow you to match incoming mail by regex and redirect it to any other mail but will break the Catch-ALL rule in the Aliases.

(Assume that you are root and repo was cloned into the /root/mailcow-dockerized)

Override main.cf

nano /root/mailcow-dockerized/data/conf/postfix/extra.cf

Add new line

virtual_alias_maps = regexp:/opt/postfix/conf/aliases-regexp

Add regex rules

nano /root/mailcow-dockerized/data/conf/postfix/aliases-regexp
/^prefix1(.*)@mydomain.com$/    catch@mydomain.com
/^prefix2(.*)@mydomain.com$/  catch@mydomain.com

Restart the postfix container

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment