[PATCH 1 of 6] email: always log emails
Thomas De Schampheleire
patrickdepinguin at gmail.com
Tue Sep 1 16:28:33 UTC 2015
# HG changeset patch
# User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
# Date 1439667433 -7200
# Sat Aug 15 21:37:13 2015 +0200
# Node ID 566907ceeb27ce5e89a971c88c7a2527c0110f7a
# Parent c9bb2d6186ba8b86a2a0695bc90ac8c8009e420c
email: always log emails
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:
More information about the kallithea-general
mailing list