mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
SparkPost: remove empty content params with template_id
When using a stored template, SparkPost disallows subject, text, and html. Django's EmailMessage default empty strings are enough to provoke "Both content object and template_id are specified" from SparkPost, so remove them (if empty) when using stored templates. Update docs and tests; add integration test for template_id. Fixes #24
This commit is contained in:
@@ -104,6 +104,15 @@ class SparkPostPayload(BasePayload):
|
||||
if recipients:
|
||||
self.params['recipients'] = recipients
|
||||
|
||||
# Must remove empty string "content" params when using stored template
|
||||
if self.params.get('template', None):
|
||||
for content_param in ['subject', 'text', 'html']:
|
||||
try:
|
||||
if not self.params[content_param]:
|
||||
del self.params[content_param]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
return self.params
|
||||
|
||||
def set_from_email(self, email):
|
||||
|
||||
Reference in New Issue
Block a user