Opened 11 years ago
Closed 11 years ago
#24416 closed Bug (fixed)
EmailMessage and send_email do not handle ugettext_lazy translated addresses correctly
| Reported by: | Mike Edmunds | Owned by: | Mike Edmunds |
|---|---|---|---|
| Component: | Core (Mail) | Version: | 1.7 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Most (all?) of the core email backends seem to have issues with lazy strings used as addresses: to, cc, etc.:
>>> from django.utils.translation import ugettext_lazy as _
>>> from django.core.mail import send_mail
>>> send_mail('Subject', 'Content', _('from@example.com'), [_('to@example.com')])
... TypeError: sequence item 0: expected str instance, __proxy__ found
(#7574 fixed this for subject and content, but not the address fields.)
Patch coming shortly.
Change History (5)
comment:1 by , 11 years ago
| Has patch: | set |
|---|
comment:2 by , 11 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:3 by , 11 years ago
I'm curious what the use case is for having translatable email addresses?
comment:4 by , 11 years ago
A reasonable use case is for the human-readable name -- you'd like the language on that to match the (lazy-translated) language of the email content:
"Customer Service <support@example.com>" "Servicio Al Cliente <support@example.com>"
It's not inconceivable that the address-part might change, too:
"Translation team <L11n-en@example.com>" "Les traducteurs <L11n-fr@example.com>"
Test case and fix: https://github.com/medmunds/django/tree/ticket_24416
Pull request: https://github.com/django/django/pull/4211