How to set a charset in email using smtplib in Python 2.7?

前端 未结 3 594
渐次进展
渐次进展 2020-12-13 10:31

I\'m writing a simple smtp-sender with authentification. Here\'s my code

    SMTPserver, sender, destination = \'smtp.googlemail.com\', \'user@gmail.com\', [         


        
3条回答
  •  时光取名叫无心
    2020-12-13 11:17

    You should encode your message-text with UTF-8

    msg = MIMEText(content.encode('utf-8'), text_subtype).
    

    More here: http://radix.twistedmatrix.com/2010/07/how-to-send-good-unicode-email-with.html

提交回复
热议问题