I am sending an email, and to send it I need to get three variables -- title, provider, and vendor_id. This is how I am getting it:
# # -*- coding: utf-8 -*-
...
## subject
title = title.encode('utf-8')
subject = "%s - %s"%(provider, title)
msg['Subject'] = subject
## content
body_text = "The following has been successfully delivered:\n\nVendor ID: %s\nProvider: %s\nTitle: %s\n\nThank you."%((vendor_id, provider, title))
content = MIMEText(body_text, 'plain')
However, when I send the email the subject is encoded correctly (which includes the title), but the body_text is not (which also includes the title). This is how it looks:
Subject: testmovieprovider - Une soirée d'enfer
Body: The following has been successfully delivered:
Vendor ID: 02352_FR
Provider: testmovieprovider
Title: Une soirée d'enfer <------ why is this happening?
Thank you.
Why is the title in the body not encoding correctly, and what would I need to change in order for it to look like the first?
Update: Thank you for the feedback. This is what worked:
MIMEText(body_text, 'plain') --> content = MIMEText(body_text, 'plain', 'UTF-8')
#encoding utf-8in top of fileContent-Typeheader withcharset="utf-8"in it?MIMEText?content = MIMEText(body_text, 'utf-8'), but that gives me no text at all in the email.content = MIMEText(body_text, 'plain', 'utf-8').