forked from Github-Mirrors/canaille
Use the 'NAME' configuration parameter in the email sender name
This commit is contained in:
parent
d8a3696b41
commit
cd3478982c
1 changed files with 10 additions and 1 deletions
|
@ -57,10 +57,19 @@ def send_email(subject, recipient, text, html, sender=None, attachements=None):
|
||||||
msg = email.message.EmailMessage()
|
msg = email.message.EmailMessage()
|
||||||
msg.set_content(text)
|
msg.set_content(text)
|
||||||
msg.add_alternative(html, subtype="html")
|
msg.add_alternative(html, subtype="html")
|
||||||
|
|
||||||
msg["Subject"] = subject
|
msg["Subject"] = subject
|
||||||
msg["From"] = sender or current_app.config["SMTP"]["FROM_ADDR"]
|
|
||||||
msg["To"] = recipient
|
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 []
|
attachements = attachements or []
|
||||||
for cid, filename, value in attachements:
|
for cid, filename, value in attachements:
|
||||||
maintype, subtype = mimetypes.guess_type(filename)[0].split("/")
|
maintype, subtype = mimetypes.guess_type(filename)[0].split("/")
|
||||||
|
|
Loading…
Reference in a new issue