From cfd9543d92dc06473b31ffaa20f59d7b3bd81280 Mon Sep 17 00:00:00 2001 From: Alexis M Date: Mon, 30 Sep 2019 12:38:30 +0200 Subject: [PATCH] Fix email sending --- copanier/emails.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/copanier/emails.py b/copanier/emails.py index 7c6be23..3d2d64a 100644 --- a/copanier/emails.py +++ b/copanier/emails.py @@ -10,6 +10,9 @@ from . import config def send(to, subject, body, html=None, copy=None, attachments=None): + if not attachments: + attachments = [] + msg = MIMEMultipart() msg.attach(MIMEText(body, "plain")) if html: @@ -28,7 +31,7 @@ def send(to, subject, body, html=None, copy=None, attachments=None): encoders.encode_base64(part) msg.attach(part) if not config.SEND_EMAILS: - return print("Sending email", str(msg)) + return print("Sending email", str(body)) try: server = smtplib.SMTP_SSL(config.SMTP_HOST) server.login(config.SMTP_LOGIN, config.SMTP_PASSWORD)