Skip to content

Create a forward rule

Request

Examples

You can add multiple email recipients by including the 'forward.recipient' parameter multiple times up to a maximum of 5.

$ curl -X POST https://api.mailgun.net/v3/forwards
  -F match='email@mg.example.com'
  -F forward.recipient=destination1@gmail.com
  -F forward.recipient=destination2@gmail.com

The match parameter can contain a wild card expression

$ curl -X POST https://api.mailgun.net/v3/forwards
  -F match='match*@mg.example.com'
  -F forward.recipient=catchall@gmail.com

Rules only support * or literal characters where * matches any sequence of characters. So a.*@example.com matches email addresses that start with a. not email addresses that start with a like a regex match would.

Security
basicAuth
Query
matchstringrequired

A wildcard expression which matches the recipient address to forward. This is a insensitive match address

forward.urlstringrequired

A URL to forward when the rule matches the recipient. May be repeated up to 3 times. Must be a valid URL that resolves

forward.recipientstringrequired

A email address to forward to when the rule matches the recipient. May be repeated up to 5 times

forward.storestringrequired

A URL which will be used to notify you when the email arrives along with a URL you can use to retrieve the message. Must be a valid URL that resolves

curl -i -X POST \
  -u '<username>:<password>' \
  'https://api.mailgun.net/v3/forwards?match=string&forward.url=string&forward.recipient=string&forward.store=string'

Responses

A 200 response

Bodyapplication/json
idstringrequired
account_idstringrequired
domain_namestringrequired
domain_idstringrequired
matchstringrequired
forwardobject(github.com-mailgun-pathfinder-httpapi-Forward)required
created_atstringrequired
updated_atstringrequired
Response
{ "id": "60d9431e582ecdc84b886284", "account_id": "646634cc58ea2b8fe43e0000", "domain_name": "my-domain.com", "domain_id": "642134nn58ea2b8fe43e0000", "match": "wild*card@example.com", "forward": { "urls": [], "recipients": [], "store": "https://my-store-url.com/store" }, "created_at": "Mon, 28 Jun 2021 03:33:50 UTC", "updated_at": "Mon, 28 Jun 2021 03:33:50 UTC" }