SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 5c40e95e authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Make mails/backends/filebased robust against AttributeError

parent 19ab74aa
No related branches found
No related tags found
No related merge requests found
......@@ -16,3 +16,7 @@ MAILCHIMP_API_KEY = get_secret("MAILCHIMP_API_KEY")
LOGGING['handlers']['scipost_file_arxiv']['filename'] = '/Users/jscaux/Sites/SciPost.org/scipost_v1/local_files/logs/arxiv.log'
LOGGING['handlers']['scipost_file_doi']['filename'] = '/Users/jscaux/Sites/SciPost.org/scipost_v1/local_files/logs/doi.log'
CROSSREF_DEPOSIT_EMAIL = 'jscaux@scipost.org'
# Customized mailbackend
EMAIL_BACKEND = "mails.backends.filebased.ModelEmailBackend"
EMAIL_BACKEND_ORIGINAL = "mails.backends.filebased.EmailBackend"
......@@ -42,9 +42,12 @@ class ModelEmailBackend(FileBacked):
body = email_message.body
subject = email_message.subject
body_html = ''
for alt in email_message.alternatives:
if alt[1] == 'text/html':
body_html += alt[0]
try:
for alt in email_message.alternatives:
if alt[1] == 'text/html':
body_html += alt[0]
except AttributeError:
pass
MailLog.objects.create(
body=body,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment