initial upload
This commit is contained in:
30
test_imap.py
Normal file
30
test_imap.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import imaplib
|
||||
import os
|
||||
from pprint import pprint
|
||||
|
||||
# source : https://pymotw.com/3/imaplib/index.html
|
||||
|
||||
def open_connection():
|
||||
# Connect to the server
|
||||
connection = imaplib.IMAP4_SSL('SSL0.OVH.NET')
|
||||
# Login to our account
|
||||
connection.login('resultats-examens@marietton.com', '9KmKPn36a')
|
||||
return connection
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
with open_connection() as c:
|
||||
# lister les mailbox
|
||||
typ, data = c.list()
|
||||
print('Response code:', typ)
|
||||
print('Response:')
|
||||
pprint(data)
|
||||
|
||||
# lire INBOX
|
||||
typ, data = c.select('INBOX')
|
||||
typ, [msg_ids] = c.search(None, 'ALL')
|
||||
print('Starting messages:', msg_ids)
|
||||
|
||||
# What are the current flags?
|
||||
typ, response = c.fetch(msg_ids, '(FLAGS)')
|
||||
print('Flags before:', response)
|
||||
Reference in New Issue
Block a user