if missing 'from_email', then 'log_message' will fail to build

This commit is contained in:
Patrick Kimber
2014-08-04 15:32:24 +01:00
parent 54d54a9e73
commit 0063fde2e5
2 changed files with 17 additions and 2 deletions

View File

@@ -112,11 +112,15 @@ class DjrillBackend(BaseEmailBackend):
message.mandrill_response = None
if not self.fail_silently:
from_email = msg_dict.get('from_email', None)
from_message = ""
if from_email:
from_message = ", from %s" % from_email
raise MandrillAPIError(
status_code=response.status_code,
response=response,
log_message="Failed to send a message to %s, from %s" %
(msg_dict['to'], msg_dict['from_email']))
log_message="Failed to send a message to %s%s" %
(msg_dict['to'], from_message))
return False
# add the response from mandrill to the EmailMessage so callers can inspect it