That works well and avoid our emails to be considered as pishing by
antispam from email servers
But in the specific context of translations there is a bug -> if the
subject of an email is translated into another language (through the
built-in django translations tools) and contains non US-ASCII characters,
by an mechanism I didn't catch, the subject is encoded as base64 and not
quoted-printable.
This results in being considered as spam by the email servers (tested on
Gandi and Gmail)...
--
Ticket URL: <https://code.djangoproject.com/ticket/33660>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => needsinfo
Comment:
Thanks for the report. However I cannot reproduce this issue with the
following test:
{{{#!diff
diff --git a/tests/mail/tests.py b/tests/mail/tests.py
index 183a0c0ab1..81921e9504 100644
--- a/tests/mail/tests.py
+++ b/tests/mail/tests.py
@@ -28,7 +28,7 @@ from django.core.mail.backends import console, dummy,
filebased, locmem, smtp
from django.core.mail.message import BadHeaderError, sanitize_address
from django.test import SimpleTestCase, override_settings
from django.test.utils import requires_tz_support
-from django.utils.translation import gettext_lazy
+from django.utils.translation import gettext_lazy, override
from django.utils.version import PY311
try:
@@ -1232,6 +1232,27 @@ class BaseEmailBackendTests(HeadersCheckMixin):
message.get_payload(decode=True).decode(), "Je t'aime très
fort"
)
+
+ def test_send_unicode_lazy(self):
+ email = EmailMessage(
+ gettext_lazy("Password reset"),
+ gettext_lazy("Password reset sent"),
+ "fr...@example.com",
+ ["t...@example.com"],
+ )
+ with override("fr"):
+ num_sent = mail.get_connection().send_messages([email])
+ self.assertEqual(num_sent, 1)
+ message = self.get_the_message()
+ self.assertEqual(
+ message["subject"],
+ "=?utf-8?q?R=C3=A9initialisation_du_mot_de_passe?=",
+ )
+ self.assertEqual(
+ message.get_payload(decode=True).decode(),
+ "Message de réinitialisation du mot de passe envoyé",
+ )
+
def test_send_long_lines(self):
"""
Email line length is limited to 998 chars by the RFC:
}}}
Can you provide a sample project or a test case?
--
Ticket URL: <https://code.djangoproject.com/ticket/33660#comment:1>