【发布时间】:2019-06-16 09:23:29
【问题描述】:
我使用 smtplib 生成了一些 python 代码来发送自动电子邮件。一切正常,但是当我发送电子邮件时,文本和 html 版本的正文有时会随机将颜色更改为紫色。有没有办法确保它总是黑色(或其他颜色)?非常感谢!!!
text = """\
Dear Dr """ + name + """,
How are you?
the budget is ready:
"""
html = """\
<html>
<body>
<p style="color: black;">Dear Dr """ + name + """,<br>
How are you?<br>
<a href="http://www.example.com">xxx</a>
has many great info.
</p>
</body>
</html>
"""
# Turn these into plain/html MIMEText objects
part1 = MIMEText(text, "plain")
part2 = MIMEText(html, "html")
# Add HTML/plain-text parts to MIMEMultipart message
# The email client will try to render the last part first
message.attach(part1)
message.attach(part2)
【问题讨论】:
-
您应该尝试找出这种紫色的来源。您发布的代码中似乎没有它的来源。什么样的电子邮件客户端?有没有view-source选项(雷鸟在CTRL+U下有选项)
-
这是 gmail 收件人在文本和 html 版本中获得紫色,,,,不确定其他颜色
-
谷歌
gmail text color purple说:support.google.com/mail/thread/3819889?hl=en