diff --git a/canaille/apputils.py b/canaille/apputils.py index 4c49963f..b18fe943 100644 --- a/canaille/apputils.py +++ b/canaille/apputils.py @@ -57,10 +57,19 @@ def send_email(subject, recipient, text, html, sender=None, attachements=None): msg = email.message.EmailMessage() msg.set_content(text) msg.add_alternative(html, subtype="html") + msg["Subject"] = subject - msg["From"] = sender or current_app.config["SMTP"]["FROM_ADDR"] msg["To"] = recipient + if sender: + msg["From"] = sender + elif current_app.config.get("NAME"): + msg["From"] = '"{}" <{}>'.format( + current_app.config.get("NAME"), current_app.config["SMTP"]["FROM_ADDR"] + ) + else: + msg["From"] = current_app.config["SMTP"]["FROM_ADDR"] + attachements = attachements or [] for cid, filename, value in attachements: maintype, subtype = mimetypes.guess_type(filename)[0].split("/")