# HG changeset patch # User Thomas De Schampheleire # Date 2015-08-15 21:37:13 # Node ID ebfab577da164e9721a15e190e42aa49a346367e # Parent c3d83238afa19b2169a60b91870a58c24d6660e4 email: better logging of misconfiguration and better debug logging Always add details about emails being sent (or attempted to be sent). When a mail server is configured, log as debug, otherwise as warning. This also adds logging of recipients and headers. diff --git a/kallithea/lib/celerylib/tasks.py b/kallithea/lib/celerylib/tasks.py --- a/kallithea/lib/celerylib/tasks.py +++ b/kallithea/lib/celerylib/tasks.py @@ -290,10 +290,19 @@ def send_email(recipients, subject, body debug = str2bool(email_config.get('debug')) smtp_auth = email_config.get('smtp_auth') - if not mail_server: - log.error("SMTP mail server not configured - cannot send mail '%s' to %s", subject, ' '.join(recipients)) - log.warning("body:\n%s", body) - log.warning("html:\n%s", html_body) + logmsg = ("Mail details:\n" + "recipients: %s\n" + "headers: %s\n" + "subject: %s\n" + "body:\n%s\n" + "html:\n%s\n" + % (' '.join(recipients), headers, subject, body, html_body)) + + if mail_server: + log.debug("Sending e-mail. " + logmsg) + else: + log.error("SMTP mail server not configured - cannot send e-mail.") + log.warning(logmsg) return False try: