Skip to content

Commit 67da2cb

Browse files
committed
Mailtrap: begin work on docs page
1 parent 9936738 commit 67da2cb

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

docs/esps/mailtrap.rst

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
.. mailtrap-backend:
2+
3+
Mailtrap
4+
========
5+
6+
Anymail integrates with `Mailtrap <https://mailtrap.io/>`_'s
7+
transactional, bulk, or test email services, using the corresponding
8+
`REST API`_.
9+
10+
.. note::
11+
12+
By default, Anymail connects to Mailtrap's transactional API servers.
13+
If you are using Mailtrap's bulk send service, be sure to change the
14+
:setting:`MAILTRAP_API_URL <ANYMAIL_MAILTRAP_API_URL>` Anymail setting
15+
as shown below. Likewise, if you are using Mailtrap's test email service,
16+
be sure to set :setting:`MAILTRAP_TESTING_ENABLED <ANYMAIL_MAILTRAP_TESTING_ENABLED>`
17+
and :setting:`MAILTRAP_TEST_INBOX_ID <ANYMAIL_MAILTRAP_TEST_INBOX_ID>`.
18+
19+
.. _REST API: https://api-docs.mailtrap.io/docs/mailtrap-api-docs/
20+
21+
22+
Settings
23+
--------
24+
25+
.. rubric:: EMAIL_BACKEND
26+
27+
To use Anymail's Mailtrap backend, set:
28+
29+
.. code-block:: python
30+
31+
EMAIL_BACKEND = "anymail.backends.mailtrap.EmailBackend"
32+
33+
in your settings.py.
34+
35+
36+
.. setting:: ANYMAIL_MAILTRAP_API_TOKEN
37+
38+
.. rubric:: MAILTRAP_API_TOKEN
39+
40+
Required for sending:
41+
42+
.. code-block:: python
43+
44+
ANYMAIL = {
45+
...
46+
"MAILTRAP_API_TOKEN": "<your API token>",
47+
}
48+
49+
Anymail will also look for ``MAILTRAP_API_TOKEN`` at the
50+
root of the settings file if neither ``ANYMAIL["MAILTRAP_API_TOKEN"]``
51+
nor ``ANYMAIL_MAILTRAP_API_TOKEN`` is set.
52+
53+
54+
.. setting:: ANYMAIL_MAILTRAP_API_URL
55+
56+
.. rubric:: MAILTRAP_API_URL
57+
58+
The base url for calling the Mailtrap API.
59+
60+
The default is ``MAILTRAP_API_URL = "https://send.api.mailtrap.io/api"``, which connects
61+
to Mailtrap's transactional service. You must change this if you are using Mailtrap's bulk
62+
send service. For example, to use the bulk send service:
63+
64+
.. code-block:: python
65+
66+
ANYMAIL = {
67+
"MAILTRAP_API_TOKEN": "...",
68+
"MAILTRAP_API_URL": "https://bulk.api.mailtrap.io/api",
69+
# ...
70+
}
71+
72+
73+
.. setting:: ANYMAIL_MAILTRAP_TESTING_ENABLED
74+
75+
.. rubric:: MAILTRAP_TESTING_ENABLED
76+
77+
Use Mailtrap's test email service by setting this to ``True``, and providing
78+
:setting:`MAILTRAP_TEST_INBOX_ID <ANYMAIL_MAILTRAP_TEST_INBOX_ID>`:
79+
80+
.. code-block:: python
81+
82+
ANYMAIL = {
83+
"MAILTRAP_API_TOKEN": "...",
84+
"MAILTRAP_TESTING_ENABLED": True,
85+
"MAILTRAP_TEST_INBOX_ID": "<your test inbox id>",
86+
# ...
87+
}
88+
89+
By default, Anymail will switch to using Mailtrap's test email service API: ``https://sandbox.api.mailtrap.io/api``.
90+
91+
.. setting:: ANYMAIL_MAILTRAP_TEST_INBOX_ID
92+
93+
.. rubric:: MAILTRAP_TEST_INBOX_ID
94+
95+
Required if :setting:`MAILTRAP_TESTING_ENABLED <ANYMAIL_MAILTRAP_TESTING_ENABLED>` is ``True``.
96+
97+
98+
.. _mailtrap-quirks:
99+
100+
Limitations and quirks
101+
----------------------
102+
103+
**merge_metadata unsupported**
104+
Mailtrap supports :ref:`ESP stored templates <esp-stored-templates>`,
105+
but does NOT support per-recipient merge data via their :ref:`batch sending <batch-send>`
106+
service.
107+
108+
109+
.. _mailtrap-webhooks:
110+
111+
Status tracking webhooks
112+
------------------------
113+
114+
If you are using Anymail's normalized :ref:`status tracking <event-tracking>`, enter
115+
the url in the Mailtrap webhooks config for your domain. (Note that Mailtrap's sandbox domain
116+
does not trigger webhook events.)
117+
118+
119+
.. _About Mailtrap webhooks: https://help.mailtrap.io/article/102-webhooks
120+
.. _Mailtrap webhook payload: https://api-docs.mailtrap.io/docs/mailtrap-api-docs/016fe2a1efd5a-receive-events-json-format

0 commit comments

Comments
 (0)