html 波斯语 对齐,在htm中使用波斯语字体发送大量HTML电子邮件

该博客探讨了在Python Flask应用中使用withmail模块发送包含波斯语字符的邮件时遇到的UnicodeEncodeError。作者分享了解决方案,聚焦于编码问题及如何适应不同语言文本的发送。
摘要由CSDN通过智能技术生成

with mail.connect() as conn:

for user in selectemail:

message1 = request.form['htmltext']

sender='garni.kh@gmail.com'

subject = "hello, %s " %user[1]

msg = Message(recipients=[user[0]],

html=message1,

subject=subject,

sender=sender

)

conn.send(msg)

这段代码在我的html中使用时效果很好

普通英文字体

但当我用波斯语字体时,它就不起作用了。

^{pr2}$

我有一个错误的烧瓶:builtins.UnicodeEncodeError

UnicodeEncodeError: 'ascii' codec can't encode character '\u0633' in position 659: ordinal not in range(128)

这是烧瓶的全部错误:File "d:\Python33\lib\site-packages\flask-0.10-py3.3.egg\flask\app.py", line 1836, in __call__

return self.wsgi_app(environ, start_response)

File "d:\Python33\lib\site-packages\flask-0.10-py3.3.egg\flask\app.py", line 1820, in wsgi_app

response = self.make_response(self.handle_exception(e))

File "d:\Python33\lib\site-packages\flask-0.10-py3.3.egg\flask\app.py", line 1403, in handle_exception

reraise(exc_type, exc_value, tb)

File "d:\Python33\lib\site-packages\flask-0.10-py3.3.egg\flask\_compat.py", line 33, in reraise

raise value

File "d:\Python33\lib\site-packages\flask-0.10-py3.3.egg\flask\app.py", line 1817, in wsgi_app

response = self.full_dispatch_request()

File "d:\Python33\lib\site-packages\flask-0.10-py3.3.egg\flask\app.py", line 1477, in full_dispatch_request

rv = self.handle_user_exception(e)

File "d:\Python33\lib\site-packages\flask-0.10-py3.3.egg\flask\app.py", line 1381, in handle_user_exception

reraise(exc_type, exc_value, tb)

File "d:\Python33\lib\site-packages\flask-0.10-py3.3.egg\flask\_compat.py", line 33, in reraise

raise value

File "d:\Python33\lib\site-packages\flask-0.10-py3.3.egg\flask\app.py", line 1475, in full_dispatch_request

rv = self.dispatch_request()

File "d:\Python33\lib\site-packages\flask-0.10-py3.3.egg\flask\app.py", line 1461, in dispatch_request

return self.view_functions[rule.endpoint](**req.view_args)

File "D:\contact\contactweb\flaskapp.py", line 160, in gotomailing

conn.send(msg)

File "d:\Python33\lib\site-packages\flask_mail.py", line 168, in send

message.as_string())

File "d:\Python33\lib\smtplib.py", line 745, in sendmail

msg = _fix_eols(msg).encode('ascii')

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值