View difference between Paste ID: sDr2pYbs and ZK2m9iTe
SHOW: | | - or go back to the newest paste.
1
import email
2
import imaplib
3
4
5
server = "imap.mail.ru"
6
port = "993"
7
login = "[email protected]"
8
password = "moms_lover"
9
imaplib.Debug = 4
10
get_mail = imaplib.IMAP4_SSL(server, port)
11
get_mail.login(login, password)
12
get_mail.select('INBOX', readonly=True)
13
typ, data = get_mail.search(None, 'UNSEEN')
14
for i in data[0].split():
15
    typ, data = get_mail.fetch(i, '(RFC822)')
16
    print(data[0][1])
17
    msg_string = data[0][1].decode('utf-8')
18
    msg = email.message_from_string(msg_string)
19
    for part in msg.walk():
20
        if part.get_content_type() == "text/plain":
21
            txt_msg = part.get_payload()
22
            print(txt_msg)
23
			#list = [txt_msg] - список для теста
24
            #print(list)
25
        else:
26
            continue
27
get_mail.close()
28
get_mail.logout()