質問

I trying my luck to manage my mailbox with python.

My example code is

for eachmail in mailbox.mbox(mboxfile):
    print eachmail['From']

I got following by printing entire content.

Delivered-To
Subject
To
Content-Type
MIME-Version
Message-Id

Is there any full document showing what are all the properties I can get from the mbox message instance? Python docs doesn't specify any of these http://docs.python.org/library/mailbox.html#mailbox.mbox

役に立ちましたか?

解決

It depends entirely on what headers are in the message. Most of them are optional. Check RFC 2076 for common ones.

他のヒント

Those are the email message headers. The specific headers will vary drastically, and you can't really count on any of them existing (even ones you would expect to exist like To, or Subject)… But Wikipedia has a pretty good list of common headers and their meanings: http://en.wikipedia.org/wiki/Email#Header_fields

Using your variables

mm=mailbox.mbox(mboxfile)
message=mm[0]
message.keys()

You can now access using mm['Subject'] or mm['Message-ID']

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top