Skip to content

Commit 2196ab8

Browse files
committed
Docs: update Mailgun links and examples
1 parent a522fb9 commit 2196ab8

File tree

1 file changed

+36
-25
lines changed

1 file changed

+36
-25
lines changed

docs/esps/mailgun.rst

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@ Mailgun
44
=======
55

66
Anymail integrates with the `Mailgun <https://mailgun.com>`_
7-
transactional email service from Rackspace, using their
8-
REST API.
7+
transactional email service, using their `messages REST API`_.
8+
9+
.. note::
10+
11+
By default, Anymail connects to Mailgun's US-based API servers.
12+
If you are using Mailgun's EU region, be sure to change the
13+
:setting:`MAILGUN_API_URL <ANYMAIL_MAILGUN_API_URL>` Anymail setting
14+
as shown below.
15+
16+
.. _messages REST API: https://documentation.mailgun.com/en/latest/api-sending.html#sending
917

1018

1119
Settings
@@ -41,6 +49,28 @@ root of the settings file if neither ``ANYMAIL["MAILGUN_API_KEY"]``
4149
nor ``ANYMAIL_MAILGUN_API_KEY`` is set.
4250

4351

52+
.. setting:: ANYMAIL_MAILGUN_API_URL
53+
54+
.. rubric:: MAILGUN_API_URL
55+
56+
The base url for calling the Mailgun API.
57+
58+
The default is ``MAILGUN_API_URL = "https://api.mailgun.net/v3"``, which connects
59+
to Mailgun's US service. You must change this if you are using Mailgun's European
60+
region:
61+
62+
.. code-block:: python
63+
64+
ANYMAIL = {
65+
"MAILGUN_API_KEY": "...",
66+
"MAILGUN_API_URL": "https://api.eu.mailgun.net/v3",
67+
# ...
68+
}
69+
70+
(Do not include your sender domain or "/messages" in the API URL. Anymail
71+
:ref:`figures this out <mailgun-sender-domain>` for you.)
72+
73+
4474
.. setting:: ANYMAIL_MAILGUN_SENDER_DOMAIN
4575

4676
.. rubric:: MAILGUN_SENDER_DOMAIN
@@ -76,27 +106,6 @@ If not provided, Anymail will attempt to validate webhooks using the
76106
the same values for new Mailgun users, but will diverge if you ever rotate either key.)
77107

78108

79-
.. setting:: ANYMAIL_MAILGUN_API_URL
80-
81-
.. rubric:: MAILGUN_API_URL
82-
83-
The base url for calling the Mailgun API. It does not include
84-
the sender domain. (Anymail :ref:`figures this out <mailgun-sender-domain>`
85-
for you.)
86-
87-
The default is ``MAILGUN_API_URL = "https://api.mailgun.net/v3"``, which connects
88-
to Mailgun's US service. You must override this if you are using Mailgun's European
89-
region:
90-
91-
.. code-block:: python
92-
93-
ANYMAIL = {
94-
"MAILGUN_API_KEY": "...",
95-
"MAILGUN_API_URL": "https://api.eu.mailgun.net/v3",
96-
# ...
97-
}
98-
99-
100109
.. _API security settings: https://app.mailgun.com/app/account/security/api_keys
101110

102111

@@ -154,10 +163,12 @@ values directly to Mailgun. You can use any of the (non-file) parameters listed
154163
155164
message = AnymailMessage(...)
156165
message.esp_extra = {
166+
'o:deliverytime-optimize-period': '24h', # use Mailgun Send Time Optimization
167+
'o:time-zone-localize': '16:00', # use Mailgun Timezone Optimization
157168
'o:testmode': 'yes', # use Mailgun's test mode
158169
}
159170
160-
.. _Mailgun sending docs: https://documentation.mailgun.com/api-sending.html#sending
171+
.. _Mailgun sending docs: https://documentation.mailgun.com/en/latest/api-sending.html#sending
161172

162173

163174
.. _mailgun-quirks:
@@ -471,7 +482,7 @@ The *action* for your route will be either:
471482
:samp:`forward("https://{random}:{random}@{yoursite.example.com}/anymail/mailgun/inbound/")`
472483
:samp:`forward("https://{random}:{random}@{yoursite.example.com}/anymail/mailgun/inbound_mime/")`
473484

474-
* *forward* is required to select Mailgun's "forward" action
485+
* *forward* is required to select Mailgun's "forward" action
475486
(Anymail does not support using the "store" action)
476487
* *random:random* is an :setting:`ANYMAIL_WEBHOOK_SECRET` shared secret
477488
* *yoursite.example.com* is your Django site

0 commit comments

Comments
 (0)