@@ -108,7 +108,7 @@ SendinBlue can handle.
108108**HTML body required **
109109 SendinBlue's API returns an error if you attempt to send a message with
110110 only a plain-text body. Be sure to :ref: `include HTML <sending-html >`
111- content for your messages.
111+ content for your messages if you are not using a template .
112112
113113 (SendinBlue *does * allow HTML without a plain-text body. This is generally
114114 not recommended, though, as some email systems treat HTML-only content as a
@@ -130,10 +130,12 @@ SendinBlue can handle.
130130 Anymail has no way to communicate an attachment's desired content-type
131131 to the SendinBlue API if the name is not set correctly.
132132
133- **Additional template limitations **
134- If you are sending using a SendinBlue template, their API doesn't support overriding the template's
135- body. See the :ref: `templates <sendinblue-templates >`
136- section below.
133+ **No attachments with templates **
134+ If you are sending using a SendinBlue template, their API doesn't support ordinary
135+ file attachments. Attempting to send an attachment with a template will result in the
136+ SendinBlue API error message, "Please don't pass attachment content & templateId in same
137+ request, instead use attachment url only."
138+ See the :ref: `templates <sendinblue-templates >` section below.
137139
138140**Single Reply-To **
139141 SendinBlue's v3 API only supports a single Reply-To address.
@@ -164,43 +166,85 @@ SendinBlue can handle.
164166Batch sending/merge and ESP templates
165167-------------------------------------
166168
167- SendinBlue supports :ref: `ESP stored templates <esp-stored-templates >`
168- populated with global merge data for all recipients, but does not
169- offer :ref: `batch sending <batch-send >` with per-recipient merge data.
170- Anymail's :attr: `~anymail.message.AnymailMessage.merge_data `
171- and :attr: `~anymail.message.AnymailMessage.merge_metadata `
172- message attributes are not supported with the SendinBlue backend.
169+ SendinBlue supports :ref: `ESP stored templates <esp-stored-templates >` populated with
170+ global merge data for all recipients, but does not offer :ref: `batch sending <batch-send >`
171+ with per-recipient merge data. Anymail's :attr: `~anymail.message.AnymailMessage.merge_data `
172+ and :attr: `~anymail.message.AnymailMessage.merge_metadata ` message attributes are not
173+ supported with the SendinBlue backend, but you can use Anymail's
174+ :attr: `~anymail.message.AnymailMessage.merge_global_data ` with SendinBlue templates.
175+
176+ SendinBlue supports two different template styles: a `new template language `_
177+ that uses Django template syntax (with ``{{ param.NAME }} `` style substitutions),
178+ and an "old" template language that used percent-delimited ``%NAME% `` style
179+ substitutions. Anymail v7.0 and later require new style templates.
180+
181+ .. versionchanged :: 7.0
182+
183+ Anymail switched to a SendinBlue API that supports the new template language
184+ and removes several limitations from the earlier template send API. But the new API
185+ does not support attachments, and can behave oddly if used with old style templates.
186+
187+ .. caution ::
188+
189+ Anymail v7.0 and later work *only * with Sendinblue's *new * template language. You should
190+ follow SendinBlue's instructions to `convert each old template `_ to the new language.
191+
192+ Although unconverted old templates may appear to work with Anymail v7.0, some
193+ features may not work properly. In particular, ``reply_to `` overrides and recipient
194+ display names are silently ignored when *old * style templates are sent with the
195+ *new * API used in Anymail v7.0.
173196
174197To use a SendinBlue template, set the message's
175198:attr: `~anymail.message.AnymailMessage.template_id ` to the numeric
176199SendinBlue template ID, and supply substitution attributes using
177- the messages 's :attr: `~anymail.message.AnymailMessage.merge_global_data `:
200+ the message 's :attr: `~anymail.message.AnymailMessage.merge_global_data `:
178201
179202 .. code-block :: python
180203
181204 message = EmailMessage(
182- subject = " My Subject" , # optional for SendinBlue templates
183- body = None , # required for SendinBlue templates
184205 to = [" [email protected] " ] # single recipient... 185206 # ...multiple to emails would all get the same message
186207 # (and would all see each other's emails in the "to" header)
187208 )
188- message.from_email = None # required for SendinBlue templates
189- message.template_id = 3 # use this SendinBlue template
209+ message.template_id = 3 # use this SendinBlue template
210+ message.from_email = None # to use the template's default sender
190211 message.merge_global_data = {
191212 ' name' : " Alice" ,
192213 ' order_no' : " 12345" ,
193214 ' ship_date' : " May 15" ,
194215 }
195216
196217 Within your SendinBlue template body and subject, you can refer to merge
197- variables using %-delimited names, e.g., `%order_no% ` or `%ship_date% `
198- from the example above.
218+ variables using Django template syntax, like ``{{ params.order_no }} `` or
219+ ``{{ params.ship_date }} `` for the example above.
220+
221+ The message's :class: `from_email <django.core.mail.EmailMessage> ` (which defaults to
222+ your :setting: `DEFAULT_FROM_EMAIL ` setting) will override the template's default sender.
223+ If you want to use the template's sender, be sure to set ``from_email `` to ``None ``
224+ *after * creating the message, as shown in the example above.
225+
226+ You can also override the template's subject and reply-to address (but not body)
227+ using standard :class: `~django.core.mail.EmailMessage ` attributes.
228+
229+ SendinBlue's template feature does not currently support providing attachment content
230+ directly with the message---you'll get a SendinBlue API error if you try. If you must
231+ send file attachments with SendinBlue templates, you can either upload them into
232+ SendinBlue's template designer, or arrange to have the attachment content hosted on
233+ a public URL and use Anymail's :attr: `~anymail.message.AnymailMessage.esp_extra `
234+ to pass the URL to the SendinBlue API (see the Anymail SendinBlue integration tests
235+ for an example of this). A better---and portable---option may be to avoid SendinBlue
236+ templates and instead render the email in your Django code, allowing you to add any
237+ file attachments you want. See :ref: `django-templates ` for details.
238+
239+ (Note that SendinBlue doesn't support *inline * image attachments at all, whether you're
240+ using a template or not.)
241+
242+
243+ .. _new template language :
244+ https://help.sendinblue.com/hc/en-us/articles/360000268730
199245
200- Note that SendinBlue's API does not permit overriding a template's
201- body. You *must * set it to `None ` as shown above,
202- or Anymail will raise an :exc: `~anymail.exceptions.AnymailUnsupportedFeature `
203- error (if you are not ignoring unsupported features).
246+ .. _convert each old template :
247+ https://help.sendinblue.com/hc/en-us/articles/360000991960
204248
205249
206250.. _sendinblue-webhooks :
0 commit comments