mailwrite.py

来自「python web programming 部分」· Python 代码 · 共 23 行

PY
23
字号
import MimeWriter

mfile = "mailmsg.txt"
f = open(mfile, "w")

w = MimeWriter.MimeWriter(f)
w.addheader("From", "Steve Holden <sholden@holdenweb.com>")
w.addheader("To", """Gentle Reader <bookuser@holdenweb.com>,
     Steve Holden <sholden@holdenweb.com>""")
w.addheader("Received", """from thinker [64.134.121.94] by mail.holdenweb.com
    (SMTPD32-6.04) id A244C78500BA; Thu, 08 Mar 2001 01:10:12 -0500""")
f = w.startbody("text/plain", prefix=0)
f.write("""
Here we have a simple message. The lack of attachments means that the message
is simple to process, as the body can simply be read from the file after the
headers have been processed into an rfc822.Message object.

regards
 Steve
""")
f.close()

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?