diff --git a/django/core/mail/message.py b/django/core/mail/message.py index 4f8c93e9e5..205c680561 100644 --- a/django/core/mail/message.py +++ b/django/core/mail/message.py @@ -168,7 +168,8 @@ class SafeMIMEText(MIMEMixin, MIMEText): def set_payload(self, payload, charset=None): if charset == "utf-8" and not isinstance(charset, Charset.Charset): has_long_lines = any( - len(line.encode()) > RFC5322_EMAIL_LINE_LENGTH_LIMIT + len(line.encode(errors="surrogateescape")) + > RFC5322_EMAIL_LINE_LENGTH_LIMIT for line in payload.splitlines() ) # Quoted-Printable encoding has the side effect of shortening long