File: pop3

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 (31 lines) | stat: -rwxr-xr-x 649 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
#!/usr/bin/python3
import poplib

print("Testing POP3")
print("Connecting")
client = poplib.POP3('localhost')
client.set_debuglevel(2)

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

client.stls()

print("Logging in")
client.user('dep8@example.com')
client.pass_('test')

print("Listing INBOX")
res, data, _ = client.list()
assert res.startswith(b'+OK')

print("Fetching and verifying test message")
for entry in data:
    _id, _ = entry.split(maxsplit=1)
    res, body, _ = client.retr(int(_id))
    if b'Subject: DEP-8 test' in body:
        break
else:
    raise AssertionError("Test message not found")

print("Done")