Regex email forwarding

Last updated on December 29, 2021

Did you know that you can configure your alias to match a specific pattern on ImprovMX using regular expressions?

A common pattern that you can setup easily and quickly is the following:

AliasForwards to

In the current case, an email sent to will be forwarded to

Yes, you read that correctly, we allow for substitutions in the regular expression you are using, allowing you to set up complex structures.

You might be a REGEX professional, and seeing a pattern like the one above might raise some eyebrows. Indeed, sending an email to “” would match the above pattern. But in practice, we surround all the regexes entries with the start and end block (“^” and “$“). So when testing, the pattern is, in reality, ^(contact|support|hello)$.

Using substitutions

Standard REGEX rules apply, and you can use the dollar sign (“$”) as a substitution in the forwarded email. The number following the dollar sign starts at 1 for the first group matched (using parenthesis).

This allows you to write interesting REGEX patterns and use the matched value in your destination email. The above example is a case that both leverages REGEX patterns, substitutions and GMail “plus” sign, but depending on your organization and the destination mail server, you can create one alias that will handle your entire organization. If all the emails follow the same pattern firstname.lastname, then it can be configured as ([a-z]+).([a-z]+).

The only restriction that applies is the maximum length of the alias field, which is 150 chars.

Order of importance when matching an email

At ImprovMX, we consider four levels of importance when searching for an alias, which are :

  1. The exact match
  2. The “Plus sign” match (more on that at the bottom of this guide)
  3. The Regex match
  4. The Wildcard or catch-all match *

Regardless of how many aliases an email matches, only the highest priority one will be taken into consideration.

For example, take the following alias configuration for

AliasForwards to

An email sent to would match the three alias configurations in this case, but ImprovMX will use the best match case, which is the exact match: “”.

Here’s a sample of emails sent, and which alias they’d match based on the configuration above:

Wait … what about the last line? WTF?! Yep, this is what we call the “Plus sign” match

The “plus sign” match

When we receive an email that contains the “+” sign, we handle them like Gmail does, whenever possible.

This means that any email sent to us with a + sign in the left part, will be considered without it when searching for an alias.

In this case, sending an email to is similar to sending an email to and will match the same result, which is “”.

But we go a bit further.

Since the matching email is a address, we already know that they work well with the plus sign too, so if the matching email is a address, and does not already have a “+” sign, we add the one we got in the original email.

Hence, sending an email to will result in the email being forwarded to

The “+anything” part is automatically added by ImprovMX.

Note: This only works for domains, and not for G-Suite domains as it would require us to test if these domains are hosted by GMail first, slowing the email processing time.

If your email provider also accepts the plus sign, don’t hesitate to let us know. We’ll add them to the list of accepted domains for the plus sign.