aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--newspipe/notifications/emails.py11
-rw-r--r--newspipe/notifications/notifications.py8
2 files changed, 9 insertions, 10 deletions
diff --git a/newspipe/notifications/emails.py b/newspipe/notifications/emails.py
index 296e793d..44b1d8b3 100644
--- a/newspipe/notifications/emails.py
+++ b/newspipe/notifications/emails.py
@@ -23,6 +23,7 @@ import logging
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
+from email import charset
from newspipe.bootstrap import application
from newspipe.web.decorators import async_maker
@@ -41,7 +42,7 @@ def send_async_email(mfrom, mto, msg):
except Exception:
logger.exception("send_async_email raised:")
else:
- s.sendmail(mfrom, mto, msg.as_string())
+ s.sendmail(mfrom, mto, msg.as_bytes().decode(encoding="UTF-8"))
s.quit()
@@ -58,19 +59,21 @@ def send_smtp(to="", subject="", plaintext="", html=""):
"""
# Create message container - the correct MIME type is multipart/alternative.
msg = MIMEMultipart("alternative")
+ ch = charset.add_charset("utf-8", charset.QP)
+ msg.set_charset(ch)
msg["Subject"] = subject
msg["From"] = application.config["MAIL_DEFAULT_SENDER"]
msg["To"] = to
# Record the MIME types of both parts - text/plain and text/html.
part1 = MIMEText(plaintext, "plain", "utf-8")
- part2 = MIMEText(html, "html", "utf-8")
+ # part2 = MIMEText(html, "html", "utf-8")
# Attach parts into message container.
# According to RFC 2046, the last part of a multipart message, in this case
# the HTML message, is best and preferred.
msg.attach(part1)
- msg.attach(part2)
+ # msg.attach(part2)
try:
s = smtplib.SMTP(application.config["MAIL_SERVER"])
@@ -85,6 +88,6 @@ def send_smtp(to="", subject="", plaintext="", html=""):
s.sendmail(
application.config["MAIL_DEFAULT_SENDER"],
msg["To"],
- msg.as_bytes().decode(encoding='UTF-8'),
+ msg.as_bytes().decode(encoding="UTF-8"),
)
s.quit()
diff --git a/newspipe/notifications/notifications.py b/newspipe/notifications/notifications.py
index 633af4c3..debbee61 100644
--- a/newspipe/notifications/notifications.py
+++ b/newspipe/notifications/notifications.py
@@ -46,9 +46,7 @@ def new_account_notification(user, email):
)
emails.send(
- to=email,
- subject="[Newspipe] Account creation",
- plaintext=plaintext,
+ to=email, subject="[Newspipe] Account creation", plaintext=plaintext,
)
@@ -58,7 +56,5 @@ def new_password_notification(user, password):
"""
plaintext = render_template("emails/new_password.txt", user=user, password=password)
emails.send(
- to=user.email,
- subject="[Newspipe] New password",
- plaintext=plaintext,
+ to=user.email, subject="[Newspipe] New password", plaintext=plaintext,
)
bgstack15