这是我现在的代码:
from email.MIMEText import MIMEText
body = "helloworld"
msg = MIMEText(body, 'plain')
msg['Subject']= subject
msg['From'] = from_field['name'] + ' <'+from_field['email']+'>'
msg['Date'] = datetime.datetime.now().strftime('%a, %d %b %Y %H:%M:%S %z')
#other code here for connecting to SMTP
conn.sendmail(from_field['email'],[to_email], msg.as_string()) #finally send the email
我当前的代码产生以下标题:
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"
但是,我希望我的代码产生以下内容:
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=iso-8859-1
我怎样才能修改我的 MIMEText 来做到这一点?