From b384f71b64d2e0a553c3702351d38352bc328907 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Thu, 13 Sep 2018 12:58:08 +0200 Subject: [PATCH] Fail silently if attachment could not be found --- src/pretix/base/services/mail.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pretix/base/services/mail.py b/src/pretix/base/services/mail.py index 8f89ee9cb..7caf15949 100644 --- a/src/pretix/base/services/mail.py +++ b/src/pretix/base/services/mail.py @@ -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) for inv in invoices: if inv.file: - email.attach( - '{}.pdf'.format(inv.number), - inv.file.file.read(), - 'application/pdf' - ) + try: + email.attach( + '{}.pdf'.format(inv.number), + inv.file.file.read(), + 'application/pdf' + ) + except: + logger.exception('Could not attach invoice to email') + pass if event: event = Event.objects.get(id=event) backend = event.get_mail_backend()