Skip to content

Commit

Permalink
fix readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ikvk committed Jun 29, 2020
1 parent f1f181a commit b06f226
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ Basic
subjects = [msg.subject for msg in mailbox.fetch(Q(all=True))]
mailbox.logout()
MailBox/MailBoxUnencrypted for create mailbox instance.

MailBox.box - imaplib.IMAP4/IMAP4_SSL client instance.

MailBox.fetch - email message generator, first searches email ids by criteria, then fetch and yields emails by one:

* *criteria* = 'ALL' message search criteria, `docs <#search-criteria>`_
Expand All @@ -56,41 +60,39 @@ MailBox.fetch - email message generator, first searches email ids by criteria, t
* *reverse* = False, in order from the larger date to the smaller
* *headers_only* = False, get only email headers (without text, html, attachments)

MailBox.box - imaplib.IMAP4/IMAP4_SSL client instance.

Email attributes
^^^^^^^^^^^^^^^^

Message and Attachment public attributes are cached by functools.lru_cache

.. code-block:: python
for message in mailbox.fetch():
message.uid # str or None: '123'
message.subject # str: 'some subject'
message.from_ # str: '[email protected]'
message.to # tuple: ('[email protected]', '[email protected]', )
message.cc # tuple: ('[email protected]', )
message.bcc # tuple: ('[email protected]', )
message.reply_to # tuple: ('[email protected]', )
message.date # datetime.datetime: 1900-1-1 for unparsed, may be naive or with tzinfo
message.date_str # str: original date - 'Tue, 03 Jan 2017 22:26:59 +0500'
message.text # str: 'hi'
message.html # str: '<b>hi</b>'
message.flags # tuple: ('SEEN', 'FLAGGED', 'ENCRYPTED')
message.headers # dict: {'Received': ('from 1.m.ru', 'from 2.m.ru'), 'AntiVirus': ('Clean',)}
for att in message.attachments: # list: [Attachment objects]
for msg in mailbox.fetch():
msg.uid # str or None: '123'
msg.subject # str: 'some subject'
msg.from_ # str: '[email protected]'
msg.to # tuple: ('[email protected]', '[email protected]', )
msg.cc # tuple: ('[email protected]', )
msg.bcc # tuple: ('[email protected]', )
msg.reply_to # tuple: ('[email protected]', )
msg.date # datetime.datetime: 1900-1-1 for unparsed, may be naive or with tzinfo
msg.date_str # str: original date - 'Tue, 03 Jan 2017 22:26:59 +0500'
msg.text # str: 'hi'
msg.html # str: '<b>hi</b>'
msg.flags # tuple: ('SEEN', 'FLAGGED', 'ENCRYPTED')
msg.headers # dict: {'Received': ('from 1.m.ru', 'from 2.m.ru'), 'AntiVirus': ('Clean',)}
for att in msg.attachments: # list: [Attachment]
att.filename # str: 'cat.jpg'
att.content_type # str: 'image/jpeg'
att.payload # bytes: b'\xff\xd8\xff\xe0\'
message.obj # email.message.Message: original object
message.from_values # dict or None: {'email': '[email protected]', 'name': 'Ya 你', 'full': 'Ya 你 <[email protected]>'}
message.to_values # tuple: ({'email': '', 'name': '', 'full': ''},)
message.cc_values # tuple: ({'email': '', 'name': '', 'full': ''},)
message.bcc_values # tuple: ({'email': '', 'name': '', 'full': ''},)
message.reply_to_values # tuple: ({'email': '', 'name': '', 'full': ''},)
msg.obj # email.message.Message: original object
msg.from_values # dict or None: {'email': '[email protected]', 'name': 'Ya 你', 'full': 'Ya 你 <[email protected]>'}
msg.to_values # tuple: ({'email': '', 'name': '', 'full': ''},)
msg.cc_values # tuple: ({'email': '', 'name': '', 'full': ''},)
msg.bcc_values # tuple: ({'email': '', 'name': '', 'full': ''},)
msg.reply_to_values # tuple: ({'email': '', 'name': '', 'full': ''},)
Search criteria
^^^^^^^^^^^^^^^
Expand Down

0 comments on commit b06f226

Please sign in to comment.