[英]Sending formatted html mail through linux
I have a python 2.2 script that builds up an html string in the following manner: 我有一个Python 2.2脚本,该脚本以以下方式构建html字符串:
html_string = ""
html_string = html_string + "MIME-Version: 1.0\n"
html_string = html_string + "Content-type: text/html\n\n"
html_string = html_string + "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">"
html_string = html_string + "<html>..."
html_string = html_string + "</html"
I then right this data to a file. 然后,我将这些数据整理到一个文件中。 Then I run the following command:
然后我运行以下命令:
os.system("mail -s \"<Subject>\" <my_email_addr> < /path/to/file/email_file")
I then receive an email, but it comes out all unformated. 然后,我收到一封电子邮件,但所有内容均未格式化。 It shows all the html tags and such.
它显示了所有的html标签等。 How do I make it show the html as it should?
如何使它按原样显示html? I'm using outlook 2010 as the mail client btw.
我正在使用Outlook 2010作为邮件客户端。
Thank you. 谢谢。
Have a look at this link which describes how to send HTML mail using various incarnations of mail
. 看一下这个链接 ,它描述了如何使用各种
mail
形式发送HTML mail
。
This isn't so much a Python programming problem as a how-do-I-invoke- mail
-to-send-HTML-mail problem. 这不是Python编程问题,而是如何将
mail
发送到HTML邮件的问题。
Of course, you could just employ the relevant Python library (email package) to do what you need to as well. 当然,您可以只使用相关的Python库(电子邮件包)来完成所需的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.