From 6946209e671ec278d7648434500aeb2639c8c3c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20Joaqu=C3=ADn=20Atria?= <jjatria@gmail.com>
Date: Mon, 18 Sep 2023 12:32:01 +0100
Subject: [PATCH] Set email charset as utf-8 rather than utf8 (#16329)

---
 changelog.d/16329.bugfix       | 1 +
 synapse/handlers/send_email.py | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)
 create mode 100644 changelog.d/16329.bugfix

diff --git a/changelog.d/16329.bugfix b/changelog.d/16329.bugfix
new file mode 100644
index 0000000000..2f1f7e8ffe
--- /dev/null
+++ b/changelog.d/16329.bugfix
@@ -0,0 +1 @@
+Use standard name for UTF-8 charset in emails.
diff --git a/synapse/handlers/send_email.py b/synapse/handlers/send_email.py
index 4f5fe62fe8..657d9b3559 100644
--- a/synapse/handlers/send_email.py
+++ b/synapse/handlers/send_email.py
@@ -174,8 +174,8 @@ class SendEmailHandler:
         if raw_to == "":
             raise RuntimeError("Invalid 'to' address")
 
-        html_part = MIMEText(html, "html", "utf8")
-        text_part = MIMEText(text, "plain", "utf8")
+        html_part = MIMEText(html, "html", "utf-8")
+        text_part = MIMEText(text, "plain", "utf-8")
 
         multipart_msg = MIMEMultipart("alternative")
         multipart_msg["Subject"] = subject
-- 
GitLab