The Definition of a Route
You can think of our Routes feature as a sophisticated filtering and forwarding mechanism. With Routes, you have a good deal of capabilities at your disposal, such as:
- Forward incoming emails to another environment for storage (such as another email address or maybe an endpoint on your server)
- Store a message temporarily (for up to 3 days) and retrieve it using our Messages API
- Stop a message from being processed (this drops certain messages instead of forwarding or storing them)
The Creation of a Route
You can set up a Route in one of two ways:
- Via the Mailgun control panel
- Via the API
For brevity's sake, we'll just cover how to set up a Route via the Control Panel in this article.
Inside the Mailgun Control Panel (options displayed down the left-hand side on a dark column), use the following instructions:
- Click on the Receiving option on the left-hand side of your Mailgun dashboard.
- Click on the specific region for which you would like to create a Route.
- Click the green Create Route button in the top-right section of the control panel.
- Fill out the information for the Expression Type, Actions, Priority, and Description field before clicking on the Create Route button to save the route.
The Features Of A Route
The first thing you will see is the Expression Type dropdown menu. This consists of the following expressions:
- Catch All - Gives you a way to catch the incoming messages for which you've not made a specific Route
- Match Recipient - This will filter any incoming messages that match a specific email address, such as email@example.com (where mail.example.com is the domain verified on your account)
- Match Headers - Similar to Match Recipient, this will filter incoming messages based on a header in the message, such as any message with the word "support" in the subject line
- Custom - Custom routes are a little more advanced; this is where you can combine a multitude of filters to really get specific. If you want to learn more, check out the docs we have on our Routes here
Next, you will need to choose among a set of Actions. We mentioned these at the beginning of the article, but we'll repeat them here for convenience:
- Forward forwards incoming emails to another environment for storage (such as another email address or maybe an endpoint on your server).
- Store and notify stores a message temporarily (for up to 3 days) where you can retrieve it using our Messages API. It also allows you to pass an endpoint or leave it empty, in which case we provide the storage URL for you to retrieve the message later via the Messages API.
- Stop stops a message from being processed (again, this drops certain messages instead of forwarding or storing them).
And finally, the last two fields are Priority and Description. In the Priority field, you can specify a priority level to determine the sequence in which the Route gets handled. Here, the lower the number, the higher the priority. The lowest number would then be handled first; like a ranking of importance. In the Description field, you can specify a description to either name or identify the Route. For instance, "Forward from subdomain1 to Alice at Example.com." This is just for your reference, to help you quickly identify just which route you're looking for.
If any questions arise, just reach out to our Support team via the Support option in your Mailgun control panel!