From 7e3012af451778d2d63452590f8a6f137ff4a808 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 3 Jun 2024 11:58:25 -0500 Subject: Log out emails in debug mode. Log out emails sent when the application is in debug mode to help with maintenance efforts. --- gn_auth/smtp.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gn_auth/smtp.py b/gn_auth/smtp.py index 42d8eae..0c9f878 100644 --- a/gn_auth/smtp.py +++ b/gn_auth/smtp.py @@ -1,4 +1,5 @@ """Handle sending emails. Uses Python3's `smtplib`.""" +import logging import smtplib import mimetypes from typing import Optional @@ -50,6 +51,7 @@ def send_message(# pylint: disable=[too-many-arguments] source_address: Optional[tuple[tuple[str, int], ...]] = None ): """Set up a connection to a SMTP server and send a message.""" + logging.debug("Email to send:\n******\n%s\n******\n", message.as_string()) with smtplib.SMTP(host, port, local_hostname, timeout, source_address) as conn: conn.starttls() conn.login(smtp_user, smtp_passwd) -- cgit v1.2.3