#27333: Different behavior py2 / py3 with Django on base64 body_encoding
EmailMessage
-----------------------------+---------------------------
     Reporter:  aRkadeFR     |      Owner:  nobody
         Type:  Bug          |     Status:  new
    Component:  Core (Mail)  |    Version:  1.8
     Severity:  Normal       |   Keywords:  email, base64
 Triage Stage:  Unreviewed   |  Has patch:  0
Easy pickings:  0            |      UI/UX:  0
-----------------------------+---------------------------
 I have a different behavior on body encoding on python 2.7.12 and python
 3.5.2 with Django 1.8.15:

 {{{
 # -*- coding: utf-8 -*-
 from __future__ import unicode_literals, absolute_import

 from django.conf import settings
 settings.configure(DATABASES={}, SECRET_KEY='not empty')

 from django.core.mail import EmailMessage


 email = EmailMessage('Chère chère', 'Super \' fort très fort.',
                      'f...@example.com', ['t...@example.com'])
 print(email.message().as_string())
 }}}

 On python 3, the body will be encoded as base64, but not on python 2.

 I've found couple of tickets relating to the same subject (#3472, and
 #11212 among others), and I've found in the Django code 1.8.15 in the file
 `django/core/mail/message.py`:
 {{{
 # Don't BASE64-encode UTF-8 messages so that we avoid unwanted attention
 from
 # some spam filters.
 utf8_charset = Charset.Charset('utf-8')
 utf8_charset.body_encoding = None  # Python defaults to BASE64
 }}}

 I would think from the code and the tickets that Django tries to never
 base64 the body of EmailMessage.

 Is it the desired behavior?

--
Ticket URL: <https://code.djangoproject.com/ticket/27333>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.4bb9933651e4c4dca8ac8de7de699908%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to