Regexes in Aliases
What Are Regex Aliases?
Use regular expressions to match patterns in email aliases and forward them dynamically. This lets you handle multiple similar addresses with a single rule.
A common pattern that you can set up easily:
Using substitutions
You can use $1, $2, etc. to insert
values matched by regex groups (parentheses) into the destination email address.
-
$1= first matched group,$2= second group, and so on. - This allows you to dynamically forward emails based on parts of the alias.
Example:
Let's say you have an alias defined as:
If someone sends an email to: [email protected]
Result: The email forwards to: [email protected]
Note: The alias field must not exceed 150 characters
Order of importance when matching an email
We evaluate alias matches in the following order of importance:
- The exact match
- The "Plus sign" match
- The Regex match
- The Wildcard or catch-all match
*
Regardless of how many aliases an email matches, only the highest priority rule activates.
Example:
Given these aliases:
Even though contact@... matches multiple rules, the exact match
i.e. "[email protected]" takes priority.
Example email matches based on the above configuration:
- [email protected] → [email protected] – Exact match
- [email protected] → [email protected] – Regex match
- [email protected] → [email protected] – Wildcard match
- [email protected] → [email protected] – Plus sign match
The "plus sign" match
When an email is sent to an address with a plus sign (e.g., [email protected]), ImprovMX:
-
Matches it to the base alias (e.g.,
[email protected]) -
Forwards to the configured destination (e.g.,
[email protected]) -
If the destination is a Gmail address, ImprovMX adds the same
+labelto the Gmail address
Example
Let's say you have the below forwarding setup:
Actual Email sent to: [email protected]
Final forwarded to: [email protected]
ImprovMX strips the +newsletter when matching the alias, but re-applies
it to the Gmail destination for consistency.
Note: Only works for @gmail.com and other domains below, not for G-Suite domains.
List of accepted domains for Regex plus sign forwarding
- gmail.com
- hey.com
- protonmail.com
- icloud.com
- fastmail.com
- outlook.com
- runbox.com
- yandex.com
- yandex.ru
- mailfence.com
If you have any questions about regex forwarding, feel free to contact us.