1
所以,這是我的代碼有,把它從python.org,但是當我發送電子郵件contaning特殊字符,如「E」或「NAO」,它顯示了這樣的「à© 「或」não「在outlook.com上,但其他電子郵件工作正常。的Python econding郵件MimeMultipart的
有沒有什麼辦法可以解決這個問題?我嘗試設置.py編碼,html meta enconding但沒有工作。
copia = str(copia)
msg = MIMEMultipart('alternative')
msg['Subject'] = assunto
msg['From'] = de
msg['To'] = para
msg['Cc'] = copia
# Create the body of the message (a plain-text and an HTML version).
text = email_texto
html = email_html
# Record the MIME types of both parts - text/plain and text/html.
part1 = MIMEText(text, 'plain')
part2 = MIMEText(html, 'html')
# Attach parts into message container.
# According to RFC 2046, the last part of a multipart message, in this case
# the HTML message, is best and preferred.
msg.attach(part1)
msg.attach(part2)
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
server.ehlo()
server.login(de, self.senha)
server.sendmail(de, (para, copia), msg.as_string())
server.quit()
歡迎使用計算器。請在您的答案中提供示例代碼,而不僅僅是一個鏈接!鏈接可能會隨着時間的推移而崩潰... – user1251007
好吧,它在Outlook上運行正常,但是當我在gmail上測試時,它沒有顯示任何內容 – leosilvano