Remove multiple attachment code - was not even done
This commit is contained in:
parent
2751b92cb8
commit
2ba70c692f
|
@ -20,7 +20,6 @@ def _send_email(
|
|||
sender="BornHack <info@bornhack.dk>",
|
||||
attachment=None,
|
||||
attachment_filename="",
|
||||
attachments=None,
|
||||
):
|
||||
if not isinstance(to_recipients, list):
|
||||
to_recipients = [to_recipients]
|
||||
|
@ -42,15 +41,11 @@ def _send_email(
|
|||
if html_template:
|
||||
msg.attach_alternative(html_template, "text/html")
|
||||
|
||||
if not attachments and attachment:
|
||||
attachments = [(attachment, attachment_filename)]
|
||||
|
||||
# is there an attachment to this mail?
|
||||
if attachments:
|
||||
for content, filename in attachments:
|
||||
if attachment
|
||||
# figure out the mimetype
|
||||
mimetype = magic.from_buffer(content, mime=True)
|
||||
msg.attach(filename, content, mimetype)
|
||||
mimetype = magic.from_buffer(attachment, mime=True)
|
||||
msg.attach(attachment_filename, attachment, mimetype)
|
||||
except Exception as e:
|
||||
logger.exception("exception while rendering email: {}".format(e))
|
||||
return False
|
||||
|
@ -76,6 +71,7 @@ def add_outgoing_email(
|
|||
sender="BornHack <info@bornhack.dk>",
|
||||
attachment=None,
|
||||
attachment_filename="",
|
||||
attachments=None,
|
||||
):
|
||||
""" adds an email to the outgoing queue
|
||||
recipients is a list of to recipients
|
||||
|
@ -104,9 +100,4 @@ def add_outgoing_email(
|
|||
bcc_recipients=bcc_recipients,
|
||||
)
|
||||
|
||||
if attachment:
|
||||
django_file = ContentFile(attachment)
|
||||
django_file.name = attachment_filename
|
||||
email.attachment.save(attachment_filename, django_file, save=True)
|
||||
|
||||
return True
|
||||
|
|
Loading…
Reference in a new issue