From 9dd4a4afb7ab311c35f3d24274384a93564315f4 Mon Sep 17 00:00:00 2001 From: Son NK Date: Mon, 9 Dec 2019 21:21:40 +0100 Subject: [PATCH] take into account NOT_SEND_EMAIL param --- app/email_utils.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/email_utils.py b/app/email_utils.py index ccc99c29..d4fd076b 100644 --- a/app/email_utils.py +++ b/app/email_utils.py @@ -5,7 +5,13 @@ from smtplib import SMTP from jinja2 import Environment, FileSystemLoader -from app.config import SUPPORT_EMAIL, ROOT_DIR, POSTFIX_SERVER, ADMIN_EMAIL +from app.config import ( + SUPPORT_EMAIL, + ROOT_DIR, + POSTFIX_SERVER, + ADMIN_EMAIL, + NOT_SEND_EMAIL, +) from app.log import LOG @@ -93,6 +99,16 @@ def send_test_email_alias(email, name): def send_by_postfix(to_email, subject, plaintext, html): + if NOT_SEND_EMAIL: + LOG.d( + "send email with subject %s to %s, plaintext: %s, html:%s", + subject, + to_email, + plaintext, + html, + ) + return + # host IP, setup via Docker network smtp = SMTP(POSTFIX_SERVER, 25) msg = EmailMessage()