mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
adding the send-template call
This commit is contained in:
@@ -45,6 +45,7 @@ class DjrillBackend(BaseEmailBackend):
|
|||||||
"in the settings.py file.")
|
"in the settings.py file.")
|
||||||
|
|
||||||
self.api_action = self.api_url + "/messages/send.json"
|
self.api_action = self.api_url + "/messages/send.json"
|
||||||
|
self.template_api_action = self.api_url + "/messages/send-template.json"
|
||||||
|
|
||||||
def send_messages(self, email_messages):
|
def send_messages(self, email_messages):
|
||||||
if not email_messages:
|
if not email_messages:
|
||||||
@@ -73,10 +74,23 @@ class DjrillBackend(BaseEmailBackend):
|
|||||||
raise
|
raise
|
||||||
return False
|
return False
|
||||||
|
|
||||||
djrill_it = requests.post(self.api_action, data=json.dumps({
|
# check if template is set in message to send it via
|
||||||
"key": self.api_key,
|
# api url: /messages/send-template.json
|
||||||
"message": msg_dict
|
if hasattr(message, 'template_name'):
|
||||||
}))
|
template_content = getattr(message, 'template_content',
|
||||||
|
None)
|
||||||
|
djrill_it = requests.post(self.template_api_action,
|
||||||
|
data=json.dumps({
|
||||||
|
"key": self.api_key,
|
||||||
|
"template_name": message.template_name,
|
||||||
|
"template_content": template_content,
|
||||||
|
"message": msg_dict
|
||||||
|
}))
|
||||||
|
else:
|
||||||
|
djrill_it = requests.post(self.api_action, data=json.dumps({
|
||||||
|
"key": self.api_key,
|
||||||
|
"message": msg_dict
|
||||||
|
}))
|
||||||
|
|
||||||
if djrill_it.status_code != 200:
|
if djrill_it.status_code != 200:
|
||||||
if not self.fail_silently:
|
if not self.fail_silently:
|
||||||
|
|||||||
Reference in New Issue
Block a user