首页 > 解决方案 > python格式文件内容发送小瓶html邮件

问题描述

我正在使用 python 使用这种方法将文件的内容发送到电子邮件:

f = open(file,"r")
contents = f.read()

在我放入的html代码中:

        <head></head>
        <body>
        <h1>Alerta</h1>
        <p>{contents}</p>
        </body>
        </html>
                    """.format(contents=contents)

该文件如下所示:

phrase 1
phrase 2
phrase 3
phrase 4

但在我收到的电子邮件中:

phrase 1 phrase 2 phrase 3 phrase 4

有没有办法以与原始文件类似的方式获取电子邮件?

标签: pythonhtmlemail

解决方案


推荐阅读