Regexes in Aliases

How to use regular expressions in your ImprovMX 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:

regex alias example

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:

alias configuration example

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:

  1. The exact match
  2. The "Plus sign" match
  3. The Regex match
  4. The Wildcard or catch-all match *

Regardless of how many aliases an email matches, only the highest priority rule activates.

Example:

Given these aliases:

multiple alias rules example

Even though contact@... matches multiple rules, the exact match i.e. "[email protected]" takes priority.

Example email matches based on the above configuration:

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 +label to the Gmail address
Example

Let's say you have the below forwarding setup:

plus sign forwarding example

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.