From 746c1c38750e47a505355e72545d6b66f6ad7123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Joaqu=C3=ADn=20Atria?= Date: Fri, 15 Sep 2023 23:23:24 +0100 Subject: [PATCH] Set email charset as utf-8 rather than utf8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As stated in [1], the charset parameter can be set to "any character encoding that has been registered with IANA". A full list of these is available in [2]. Notably missing from that list is the `utf8` value that was being used for email charsets. The strictly more correct name is `utf-8` (or `UTF-8`, since these names are case-insensitive). The popularity of UTF-8 has meant that aliases like `utf8` are supported by a number of email servers. Unfortunately, not all are as accommodating (see for example [3]), so a more standard name means Synapse can be used even with the more opinionated servers. [1]: https://www.w3.org/International/articles/http-charset/index [2]: http://www.iana.org/assignments/character-sets/character-sets.xhtml [3]: https://github.com/emersion/hydroxide/issues/165 Signed-off-by: José Joaquín Atria --- 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 000000000000..2f1f7e8ffe54 --- /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 4f5fe62fe802..657d9b35591f 100644 --- a/synapse/handlers/send_email.py +++ b/synapse/handlers/send_email.py @@ -174,8 +174,8 @@ async def send_email( 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