Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- def sanitise(msg):
- fn = msg.get_filename()
- if fn:
- msg.set_payload("Attachment stripped"
- "\nFilename: " + fn +
- "\nContent-Type: " + msg.get_content_type())
- for k, v in msg.get_params()[1:]:
- msg.del_param(k)
- msg.set_type('text/plain')
- del msg['Content-Transfer-Encoding']
- del msg['Content-Disposition']
- else:
- if msg.is_multipart():
- msg.set_payload([ sanitise(x) for x in msg.get_payload() ])
- return msg
- import mailbox, email, sys
- reload(sys)
- sys.setdefaultencoding('utf-8')
- mbox = mailbox.mbox(sys.argv[1], factory=None, create=False)
- for k, m in mbox.iteritems():
- print(sanitise(m).as_string())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement