Code

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#3398 closed (duplicate)

send_mass_mail confused by non-ascii characters

Reported by: anonymous Owned by: adrian
Component: Core (Mail) Version: master
Severity: Keywords: unicode
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:

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 (0)

Change History (2)

comment:1 Changed 7 years ago by Michael Radziej <mir@…>

  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

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

comment:2 Changed 7 years ago by mtredinnick

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.