Opened 10 years ago

Closed 10 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:2 by Markus Holtermann, 10 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Tim Graham, 10 years ago

I'm curious what the use case is for having translatable email addresses?

comment:4 by Mike Edmunds, 10 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>"

comment:5 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: newclosed

In 5993b52:

Fixed #24416 -- Added support for lazy email addresses.

Note: See TracTickets for help on using tickets.
Back to Top