#!/usr/local/bin/python # # Test script to fiddle with Python's email message (rfc822, mime, etc.) # parsing and MH mailbox support. # import sys import email # boilerplate version checking if sys.hexversion < 0x020202F0: # require version 2.1 or greater raise "python version 2.2.2 or higher required" # Takes one argument - that argument is the file path of the message we wish # to parse. # if len(sys.argv) < 2 or len(sys.argv) > 3: print "Error expected one argument: Path to message to parse" sys.exit(1) pass msg_file = sys.argv[1] file = file(msg_file, 'r') msg = email.Parser.parse(fp = file, headersonly = True) #msg = email.message_from_file(fp = file) if 'message-id' in msg: print 'Message-ID: ', msg['message-id'] pass