File: imap

package info (click to toggle)
dovecot 1%3A2.4.1%2Bdfsg1-9
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 46,392 kB
  • sloc: ansic: 596,205; makefile: 7,826; sh: 6,141; cpp: 1,866; perl: 487; yacc: 412; lex: 320; python: 299; xml: 232
file content (38 lines) | stat: -rwxr-xr-x 730 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/python3
import imaplib

imaplib.Debug = 4

print("Testing IMAP")
print("Connecting")
client = imaplib.IMAP4('localhost')

print("Checking for STARTTLS capability")
assert 'STARTTLS' in client.capabilities

client.starttls()

print("Logging in")
client.login('dep8@example.com', 'test')

print("Selecting INBOX")
client.select()

print("Looking for the test message")
res, uids = client.search(None, 'HEADER', 'MESSAGE-ID', '"<dep8-test-1@debian.org>"')

assert res == 'OK'
assert len(uids[0]) > 0

uid = uids[0].split()[0]

print("Fetching and verifying test message")
res, data = client.fetch(uid, '(RFC822)')

assert res == 'OK'

lines = data[0][1].splitlines()

assert b'Subject: DEP-8 test' in lines

print("Done")