"Help! I want Mailgun to take care of my emails, but I don't know how to set it up!", you exclaim! Well, you have come to the right place!
You can think of our Routes feature as a sophisticated filtering and forwarding mechanism. With them, you can do quite a few things! 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)
Now, on to the fun bit! The thing you've most been waiting for!
How to set up 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 will only cover how to set up a Route in this article via the Control Panel.
So, when you want to set up a Route, you will want to navigate to the Routes tab in the Mailgun Control Panel:
Once you are here, go ahead and click on the "Create Route" button, this will take you to the form where you can start filling out all the details for your new 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 you have not made a specific Route for
- Match Recipient - This will filter any incoming messages that match a specific email address, such as firstname.lastname@example.org (where mail.example.com is the domain tied to 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 see your Actions table:
Here, we kind of brushed up on already at the top of this page, but since you're already here:
- 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 the Priority and Description fields, which are pretty self-explanatory, but we'll cover them anyways!
In the Priority field, you can specify a priority level in which the Route gets handled. Here, the lower the number, the higher the priority. The highest priority would then be handled first.
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"
After you have filled out these fields to your liking, be sure to hit the "Create Route" button at the bottom to create and save your new route's settings!
That's all folks! Have a wonderful day!