2015-05-18 | Paul Boddie | file changeset files shortlog | Added testing templates and a tool to show encoded mail messages. |
paul@564 | 1 | from email import message_from_file |
paul@564 | 2 | import sys |
paul@564 | 3 | |
paul@564 | 4 | def decode(part): |
paul@564 | 5 | for key, value in part.items(): |
paul@564 | 6 | print "%s: %s" % (key, value) |
paul@564 | 7 | print |
paul@564 | 8 | decoded = part.get_payload(decode=True) |
paul@564 | 9 | if decoded: |
paul@564 | 10 | print decoded |
paul@564 | 11 | print |
paul@564 | 12 | else: |
paul@564 | 13 | for part in part.get_payload(): |
paul@564 | 14 | decode(part) |
paul@564 | 15 | |
paul@564 | 16 | message = message_from_file(sys.stdin) |
paul@564 | 17 | decode(message) |