Define a list of routes to handle incoming emails. When a message matches a route expression, Mailgun can forward it on to your application via HTTP or another email address, or store the message temporarily (3 days) for subsequent retrieval.
Adds a new route to the account
{ "priority": 0, "description": "it's a new route", "expression": "match_recipient('.*@gmail.com')", "action": [ "forward(\"http://myhost.com/messages/\")" ] }
{- "message": "Route has been created",
- "route": {
- "id": "4f3bad2335335426750048c6",
- "priority": 0,
- "description": "it's a new route",
- "expression": "match_recipient('.*@gmail.com')",
- "actions": [
- "forward(\"http://myhost.com/messages/\")"
], - "created_at": "Wed, 15 Feb 2012 13:03:31 GMT"
}
}
Get the list of routes. Note that routes are defined globally, per account, not per domain.
{- "total_count": 1,
- "items": [
- {
- "id": "4f3bad2335335426750048c6",
- "priority": 0,
- "description": "Sample route",
- "expression": "match_recipient(\".*@samples.mailgun.org\")",
- "actions": [
- "forward(\"http://myhost.com/messages/\")",
- "stop()"
], - "created_at": "Wed, 15 Feb 2012 13:03:31 GMT"
}
]
}
{- "route": {
- "id": "4f3bad2335335426750048c6",
- "priority": 0,
- "description": "Sample route",
- "expression": "match_recipient(\".*@samples.mailgun.org\")",
- "actions": [
- "forward(\"http://myhost.com/messages/\")",
- "stop()"
], - "created_at": "Wed, 15 Feb 2012 13:03:31 GMT"
}
}
Updates a given route. All parameters are optional. This only updates the specified fields, leaving others unchanged.
{ "id": "4f3bad2335335426750048c6", "priority": 0, "description": "Sample route", "expression": "match_recipient(\".*@samples.mailgun.org\")", "action": [ "forward(\"http://myhost.com/messages/\")", "stop()" ] }
{- "message": "Route has been updated",
- "route": {
- "id": "4f3bad2335335426750048c6",
- "priority": 0,
- "description": "Sample route",
- "expression": "match_recipient(\".*@samples.mailgun.org\")",
- "actions": [
- "forward(\"http://myhost.com/messages/\")",
- "stop()"
], - "created_at": "Wed, 15 Feb 2012 13:03:31 GMT"
}
}
Checks if an address matches at least one route.
{- "route": {
- "id": "4f3bad2335335426750048c6",
- "priority": 0,
- "description": "Sample route",
- "expression": "match_recipient(\".*@samples.mailgun.org\")",
- "actions": [
- "forward(\"http://myhost.com/messages/\")",
- "stop()"
], - "created_at": "Wed, 15 Feb 2012 13:03:31 GMT"
}
}