Message Parsing : email « Network « Python Tutorial






import sys, email

msg = email.message_from_file(sys.stdin)
print " *** Headers in message: "
for header, value in msg.items():
    print header + ":"
    print "  " + value

if msg.is_multipart():
    print "exiting."
    sys.exit(1)

if 'subject' in msg:
    print "Subject: ", msg['subject']
print msg.get_payload()








21.25.email
21.25.1.MIME message generation with 8-bit headers
21.25.2.# MIME Header Parsing
21.25.3.MIME Message Parsing
21.25.4.Message Generation with Date and Message-ID
21.25.5.Message Generation
21.25.6.Message Parsing