﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27333	EmailMessage.message().as_string() incorrectly base64 encoded on Python 3	aRkadeFR	Claude Paroz	"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.',
                     'from@example.com', ['to@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?"	Bug	closed	Core (Mail)	dev	Normal	fixed	email, base64		Ready for checkin	1	0	0	0	0	0
