File: tls.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 (18 lines) | stat: -rw-r--r-- 537 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""

If you want to use really secure connection, you MUST read this articles:

https://docs.python.org/3/library/imaplib.html#imaplib.IMAP4_SSL
https://docs.python.org/3/library/ssl.html#ssl-security

"""

import ssl

from imap_tools import MailBoxTls

ssl_context = ssl.create_default_context()
ssl_context.load_cert_chain(certfile="./one.crt", keyfile="./one.key")
with MailBoxTls('imap.my.ru', ssl_context=ssl_context).login('acc', 'pwd', 'INBOX') as mailbox:
    for msg in mailbox.fetch():
        print(msg.subject, msg.date_str)