Add SendinBlue backend

Add support for sending transactional email through SendinBlue. (Thanks to @RignonNoel.)

Partially implements #84. (Tracking webhooks will be a separate PR. SendinBlue doesn't support inbound handling.)
This commit is contained in:
Rignon Noël
2018-02-26 12:46:10 -05:00
committed by Mike Edmunds
parent fffd762f56
commit dc2b4b4e7a
6 changed files with 922 additions and 19 deletions

View File

@@ -17,6 +17,7 @@ and notes about any quirks or limitations:
mandrill
postmark
sendgrid
sendinblue
sparkpost
@@ -27,32 +28,32 @@ The table below summarizes the Anymail features supported for each ESP.
.. currentmodule:: anymail.message
============================================ ========== ========== ========== ========== ========== ===========
Email Service Provider |Mailgun| |Mailjet| |Mandrill| |Postmark| |SendGrid| |SparkPost|
============================================ ========== ========== ========== ========== ========== ===========
============================================ ========== ========== ========== ========== ========== ============ ===========
Email Service Provider |Mailgun| |Mailjet| |Mandrill| |Postmark| |SendGrid| |SendinBlue| |SparkPost|
============================================ ========== ========== ========== ========== ========== ============ ===========
.. rubric:: :ref:`Anymail send options <anymail-send-options>`
---------------------------------------------------------------------------------------------------------------------
:attr:`~AnymailMessage.metadata` Yes Yes Yes No Yes Yes
:attr:`~AnymailMessage.send_at` Yes No Yes No Yes Yes
:attr:`~AnymailMessage.tags` Yes Max 1 tag Yes Max 1 tag Yes Max 1 tag
:attr:`~AnymailMessage.track_clicks` Yes Yes Yes Yes Yes Yes
:attr:`~AnymailMessage.track_opens` Yes Yes Yes Yes Yes Yes
-----------------------------------------------------------------------------------------------------------------------------------
:attr:`~AnymailMessage.metadata` Yes Yes Yes No Yes Yes Yes
:attr:`~AnymailMessage.send_at` Yes No Yes No Yes No Yes
:attr:`~AnymailMessage.tags` Yes Max 1 tag Yes Max 1 tag Yes Max 1 tag Max 1 tag
:attr:`~AnymailMessage.track_clicks` Yes Yes Yes Yes Yes No Yes
:attr:`~AnymailMessage.track_opens` Yes Yes Yes Yes Yes No Yes
.. rubric:: :ref:`templates-and-merge`
---------------------------------------------------------------------------------------------------------------------
:attr:`~AnymailMessage.template_id` No Yes Yes Yes Yes Yes
:attr:`~AnymailMessage.merge_data` Yes Yes Yes No Yes Yes
:attr:`~AnymailMessage.merge_global_data` (emulated) Yes Yes Yes Yes Yes
-----------------------------------------------------------------------------------------------------------------------------------
:attr:`~AnymailMessage.template_id` No Yes Yes Yes Yes Yes Yes
:attr:`~AnymailMessage.merge_data` Yes Yes Yes No Yes No Yes
:attr:`~AnymailMessage.merge_global_data` (emulated) Yes Yes Yes Yes Yes Yes
.. rubric:: :ref:`Status <esp-send-status>` and :ref:`event tracking <event-tracking>`
---------------------------------------------------------------------------------------------------------------------
:attr:`~AnymailMessage.anymail_status` Yes Yes Yes Yes Yes Yes
|AnymailTrackingEvent| from webhooks Yes Yes Yes Yes Yes Yes
-----------------------------------------------------------------------------------------------------------------------------------
:attr:`~AnymailMessage.anymail_status` Yes Yes Yes Yes Yes Yes Yes
|AnymailTrackingEvent| from webhooks Yes Yes Yes Yes Yes No Yes
.. rubric:: :ref:`Inbound handling <inbound>`
---------------------------------------------------------------------------------------------------------------------
|AnymailInboundEvent| from webhooks Yes Yes Yes Yes Yes Yes
============================================ ========== ========== ========== ========== ========== ===========
-----------------------------------------------------------------------------------------------------------------------------------
|AnymailInboundEvent| from webhooks Yes Yes Yes Yes Yes No Yes
============================================ ========== ========== ========== ========== ========== ============ ===========
Trying to choose an ESP? Please **don't** start with this table. It's far more
@@ -65,6 +66,7 @@ meaningless. (And even specific features don't matter if you don't plan to use t
.. |Mandrill| replace:: :ref:`mandrill-backend`
.. |Postmark| replace:: :ref:`postmark-backend`
.. |SendGrid| replace:: :ref:`sendgrid-backend`
.. |SendinBlue| replace:: :ref:`sendinblue-backend`
.. |SparkPost| replace:: :ref:`sparkpost-backend`
.. |AnymailTrackingEvent| replace:: :class:`~anymail.signals.AnymailTrackingEvent`
.. |AnymailInboundEvent| replace:: :class:`~anymail.signals.AnymailInboundEvent`

90
docs/esps/sendinblue.rst Normal file
View File

@@ -0,0 +1,90 @@
.. _sendinblue-backend:
SendinBlue
========
Anymail integrates with the `SendinBlue`_ email service, using their `Web API v3`_.
.. important::
**Troubleshooting:**
If your SendinBlue messages aren't being delivered as expected, be sure to look for
events in your SendinBlue `statistic panel`_.
SendGrid detects certain types of errors only *after* the send API call appears
to succeed, and reports these errors in the statistic panel.
.. _SendinBlue: https://www.sendinblue.com/
.. _Web API v3: https://developers.sendinblue.com/docs
.. _statistic panel: https://app-smtp.sendinblue.com/statistics
Settings
--------
.. rubric:: EMAIL_BACKEND
To use Anymail's SendinBlue backend, set:
.. code-block:: python
EMAIL_BACKEND = "anymail.backends.sendinblue.EmailBackend"
in your settings.py.
.. setting:: ANYMAIL_SENDINBLUE_API_KEY
.. rubric:: SENDINBLUE_API_KEY
The API key can be retrieved from the
`account settings`_. Make sure to get the
key for the version of the API you're
using..)
Required.
.. code-block:: python
ANYMAIL = {
...
"SENDINBLUE_API_KEY": "<your API key>",
}
Anymail will also look for ``SENDINBLUE_API_KEY`` at the
root of the settings file if neither ``ANYMAIL["SENDINBLUE_API_KEY"]``
nor ``ANYMAIL_SENDINBLUE_API_KEY`` is set.
.. _account settings: https://account.sendinblue.com/advanced/api
Limitations and quirks
----------------------
**Single Reply-To**
SendinBlue's v3 API only supports a single Reply-To address.
If your message has multiple reply addresses, you'll get an
:exc:`~anymail.exceptions.AnymailUnsupportedFeature` error---or
if you've enabled :setting:`ANYMAIL_IGNORE_UNSUPPORTED_FEATURES`,
Anymail will use only the first one.
**Attachment content-type**
Attachment content-type is determined from the filename
extension and you can't specify a different one. Trying
to send an attachment without a name or a name without
an extension generates an error with SendinBlue's API.
**Inline images**
SendinBlue doesn't support inline images at all, it
only support basic attachment.
**Email's display-names**
Email's display-names are only supported
**without** :attr:`template_id`. If you specify
a :attr:`template_id` all display-names will be hidden.
**Template's limitation**
If you use a template you will suffer some limitations:
you can't change the subject or/and the body, and all email's
display-names will be hidden.