|
4 | 4 | ======= |
5 | 5 |
|
6 | 6 | 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 |
9 | 17 |
|
10 | 18 |
|
11 | 19 | Settings |
@@ -41,6 +49,28 @@ root of the settings file if neither ``ANYMAIL["MAILGUN_API_KEY"]`` |
41 | 49 | nor ``ANYMAIL_MAILGUN_API_KEY`` is set. |
42 | 50 |
|
43 | 51 |
|
| 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 | + |
44 | 74 | .. setting:: ANYMAIL_MAILGUN_SENDER_DOMAIN |
45 | 75 |
|
46 | 76 | .. rubric:: MAILGUN_SENDER_DOMAIN |
@@ -76,27 +106,6 @@ If not provided, Anymail will attempt to validate webhooks using the |
76 | 106 | the same values for new Mailgun users, but will diverge if you ever rotate either key.) |
77 | 107 |
|
78 | 108 |
|
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 | | -
|
100 | 109 | .. _API security settings: https://app.mailgun.com/app/account/security/api_keys |
101 | 110 |
|
102 | 111 |
|
@@ -154,10 +163,12 @@ values directly to Mailgun. You can use any of the (non-file) parameters listed |
154 | 163 |
|
155 | 164 | message = AnymailMessage(...) |
156 | 165 | 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 |
157 | 168 | 'o:testmode': 'yes', # use Mailgun's test mode |
158 | 169 | } |
159 | 170 |
|
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 |
161 | 172 |
|
162 | 173 |
|
163 | 174 | .. _mailgun-quirks: |
@@ -471,7 +482,7 @@ The *action* for your route will be either: |
471 | 482 | :samp:`forward("https://{random}:{random}@{yoursite.example.com}/anymail/mailgun/inbound/")` |
472 | 483 | :samp:`forward("https://{random}:{random}@{yoursite.example.com}/anymail/mailgun/inbound_mime/")` |
473 | 484 |
|
474 | | - * *forward* is required to select Mailgun's "forward" action |
| 485 | + * *forward* is required to select Mailgun's "forward" action |
475 | 486 | (Anymail does not support using the "store" action) |
476 | 487 | * *random:random* is an :setting:`ANYMAIL_WEBHOOK_SECRET` shared secret |
477 | 488 | * *yoursite.example.com* is your Django site |
|
0 commit comments