zhangyunhao116 / zmail

Zmail makes it easier to send and retrieve emails in python3
MIT License
433 stars 111 forks source link

关于send_mail中content_html带有中文会报错的问题 #82

Closed cruisin123 closed 4 years ago

cruisin123 commented 4 years ago

发送邮件时如果content_html带有中文会报错,但主题中有中文却没有问题。 { 'subject': '主题', 'content_html': '

正文[二哈]

', 'attachments': [] } 发送邮件内容如上,在flask中使用了wangeditor的富文本编辑器作为content_html接收,当content_html中不带有中文时候发送成功,但当content_html带有中文就报错了(在windows环境和centos中都是这样,但如果把上面的内容直接放到idle或者命令行中执行是发送成功的)。 错误如下: 'ascii' codec can't encode characters in position 365-380: ordinal not in range(128)。 请问是否有什么解决方案或者是我的发送姿势不对吗。

zhangyunhao116 commented 4 years ago

麻烦给下这个报错的上下文调用 看看是哪部分的问题

cruisin123 commented 4 years ago

image 代码如图。 只要content或content_html中带有中文都会报 'ascii' codec can't encode characters in position 305-306: ordinal not in range(128), 但把相同的内容直接在命令行 终端或是在idle中都能正常发送

zhangyunhao116 commented 4 years ago

感觉是环境问题 这个问题ascii溢出了 可以给一下报错的具体位置么? 我看看是standard library还是zmail的报错

cruisin123 commented 4 years ago

目前已经另起一个服务来做发送了,能正常运行,应该不是zmail的报错。但对比之前报错的配置信息,两个不同的服务的配置差异只有sqlalchemy的配置项以及log的配置信息。