From b99b55e42664860c496c86a3bb1c0ce2377f80d0 Mon Sep 17 00:00:00 2001 From: Will Stott Date: Wed, 6 Sep 2017 16:22:06 +0100 Subject: [PATCH] Miscellaneous debug log additions. --- helpdesk/lib.py | 11 ++++++++++- helpdesk/management/commands/get_email.py | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/helpdesk/lib.py b/helpdesk/lib.py index 10f4eb00..828a70c6 100644 --- a/helpdesk/lib.py +++ b/helpdesk/lib.py @@ -9,6 +9,7 @@ lib.py - Common functions (eg multipart e-mail) import logging import mimetypes import os +from smtplib import SMTPException try: # Python 2 support @@ -135,7 +136,15 @@ def send_templated_mail(template_name, content = attachedfile.read() msg.attach(filename, content) - return msg.send(fail_silently) + logger.debug('Sending email to: {!r}'.format(recipients)) + + try: + return msg.send() + except SMTPException: + logger.exception('SMTPException raised while sending email to {}'.format(recipients)) + if not fail_silently: + raise e + return 0 def query_to_dict(results, descriptions): diff --git a/helpdesk/management/commands/get_email.py b/helpdesk/management/commands/get_email.py index 8f0a4661..4b979fcc 100755 --- a/helpdesk/management/commands/get_email.py +++ b/helpdesk/management/commands/get_email.py @@ -447,7 +447,7 @@ def ticket_from_message(message, queue, logger): attached = process_attachments(f, files) for att_file in attached: - logger.info("Attachment '%s' successfully added to ticket from email." % att_file[0]) + logger.info("Attachment '%s' (with size %s) successfully added to ticket from email." % (att_file[0], att_file[1].size)) context = safe_template_context(t)