kootenpv / yagmail

Send email in Python conveniently for gmail using yagmail
MIT License
2.66k stars 265 forks source link

Set the charset of MIMEText to UTF-8 #32

Closed shuding closed 8 years ago

shuding commented 8 years ago

Hi there =) I tried to send an email which contains some CJK characters using yagmail this afternoon but got an error:

UnicodeEncodeError: 'ascii' codec can't encode characters in position 39-40: ordinal not in range(128)

It turns out that email.mime.text.MIMEText uses us-ascii as its default charset, and any non-ascii char will raise errors.

Thanks!

kootenpv commented 8 years ago

Thanks a lot for your contribution, I wasn't aware!

kootenpv commented 8 years ago

The changes are included on pip, yagmail version 0.4.129 (you can upgrade using pip install -U yagmail)

shuding commented 8 years ago

@kootenpv Now it works pretty well and thanks for merging!

kootenpv commented 8 years ago

I now made it optional (though still the default value).