Django

Code

Ticket #3398 (closed: duplicate)

Opened 2 years ago

Last modified 1 year ago

send_mass_mail confused by non-ascii characters

Reported by: anonymous Assigned to: adrian
Milestone: Component: django.core.mail
Version: SVN Keywords: unicode
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 1 Patch needs improvement: 0

Description

send_mass_mail barfs with UnicodeEncodeError? when handed a non-ascii unicode instance, here's a q&d fix.

Index: mail.py
===================================================================
--- mail.py     (wersja 4451)
+++ mail.py     (kopia robocza)
@@ -50,6 +50,8 @@
         if not recipient_list:
             continue
         from_email = from_email or settings.DEFAULT_FROM_EMAIL
+        if isinstance(message, unicode):
+            message = message.encode(settings.DEFAULT_CHARSET)
         msg = SafeMIMEText(message, 'plain', settings.DEFAULT_CHARSET)
         msg['Subject'] = subject
         msg['From'] = from_email

Attachments

Change History

01/29/07 20:23:38 changed by Michael Radziej <mir@noris.de>

  • status changed from new to closed.
  • needs_better_patch changed.
  • resolution set to duplicate.
  • needs_tests set to 1.
  • needs_docs changed.

At the present time, you shouldn't use unicode strings in any place except newforms. I close this as a duplicate of our general unicodification ticket, #2489

05/18/07 13:23:34 changed by mtredinnick

(In [5282]) unicode: Added support for sending email that contains unicode data. Refs #3398.


Add/Change #3398 (send_mass_mail confused by non-ascii characters)




Change Properties
Action