File: email_size.py

package info (click to toggle)
imap-tools 1.10.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,624 kB
  • sloc: python: 4,709; makefile: 5
file content (11 lines) | stat: -rw-r--r-- 503 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
from imap_tools import MailBox

# get size of message and attachments
with MailBox('imap.my.ru').login('acc', 'pwd', 'INBOX') as mailbox:
    for msg in mailbox.fetch():
        print(msg.date_str, msg.subject)
        print('-- RFC822.SIZE message size', msg.size_rfc822)
        print('-- bytes size', msg.size)  # will returns headers size only when fetch headers_only=True
        for att in msg.attachments:
            print('---- ATT:', att.filename)
            print('-- bytes size', att.size)