Closed spheroid closed 9 years ago
Could you provide an example where this fails? (This change would need a test case.)
Djrill call's Django's own sanitize_address here, in the same way that Django's smtp.EmailBackend does. So if there's a problem with using a lazy string as the to-address, it probably also exists in Django.
Hmm... It looks like Django's sanitize_address already tries to call force_text on the address (and this code hasn't changed since at least Django 1.3) -- so Djrill shouldn't need to force_text as well. Maybe the test for "is-string-like" in Django's sanitize_address is wrong?
Yeah, this seems to be a bug in Django core mail. I think it would be better fixed there, rather than working around it in Djrill.
Reported as Django #24416. Patch in django/django#4211.
In the meantime, if this is impacting your use of Djrill, I'd suggest calling force_text on the sender address at the point where you're building the EmailMessage object.
I was looking at that line of code as well, but didn't feel bold enough to blame it on them. :-) I worked around the problem in the meantime by extending the Djrill backend with custom one that does this. I'm unable to control all the places email gets sent (Django error handler for instance) so the code relies on DEFAULT_FROM_EMAIL which needs to be lazy.
Thank you.
Defining sender email as ugettext_lazy object breaks the Djrill backend:
Forcing the value to be evaluated before it is being broken into pieces seems to fix the issue.