Fail silently if attachment could not be found

This commit is contained in:
Raphael Michel
2018-09-13 12:58:08 +02:00
parent 10dd5278e7
commit b384f71b64

View File

@@ -176,11 +176,15 @@ def mail_send_task(*args, to: List[str], subject: str, body: str, html: str, sen
invoices = Invoice.objects.filter(pk__in=invoices) invoices = Invoice.objects.filter(pk__in=invoices)
for inv in invoices: for inv in invoices:
if inv.file: if inv.file:
email.attach( try:
'{}.pdf'.format(inv.number), email.attach(
inv.file.file.read(), '{}.pdf'.format(inv.number),
'application/pdf' inv.file.file.read(),
) 'application/pdf'
)
except:
logger.exception('Could not attach invoice to email')
pass
if event: if event:
event = Event.objects.get(id=event) event = Event.objects.get(id=event)
backend = event.get_mail_backend() backend = event.get_mail_backend()