gpt4 book ai didi

python - HTML 代码中不需要的 bang(!)

转载 作者:行者123 更新时间:2023-12-01 05:37:35 27 4
gpt4 key购买 nike

我遇到一个问题,我的 HTML 代码中出现 BANG(!)@ http://pastie.org/8289379当使用下面的python中的“sendmail”函数发送电子邮件时,我已阅读帖子@ HTML中的感叹号电子邮件解析是将其更改为base-64编码数据或在我的长行html代码中添加\r\n,am不确定如何将 HTML 代码更改为 base-64 编码?有人有其他想法来摆脱这个爆炸(!)吗?

msg = MIMEText("%s" % body, 'html')
msg['Content-Type'] = "text/html; charset=ascii"
s = SMTP('localhost',25)
s.sendmail('userid@company.com', ['userid2@company.com'],msg=msg.as_string()

最佳答案

此处提供一些信息:http://bugs.python.org/issue6327

Note that mailservers have a 990-character limit on each line contained within an email message. If an email message is sent that contains lines longer than 990-characters, those lines will be subdivided by additional line ending characters, which can cause corruption in the email message, particularly for HTML content. To prevent this from occurring, add your own line-ending characters at appropriate locations within the email message to ensure that no lines are longer than 990 characters.

我认为你必须将你的 html 分成几行。您可以使用textwrap.wrap方法。

关于python - HTML 代码中不需要的 bang(!),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18567452/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com