/
nameAddr
executable file
·58 lines (45 loc) · 1.66 KB
/
nameAddr
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
from cookie.test import *
from untwisted import smtp
expect(3)
@sdfg
def _():
for cursor in conn:
cursor.execute('INSERT INTO address (address, sender) VALUES (%s, %s)', 'bob@example.com', 'abc123')
#@...
@untwisted.identity(listen().then)
class server(smtp.server):
@untwisted.each
def mail():
ctx = yield
class sample(smtp.server.mail):
sender = staticmethod(untwisted.each(lambda: equal('abc123@nottheoilrig.com', str((yield)))))
recipient = staticmethod(untwisted.each(lambda: equal('bob@example.com', str((yield)))))
content = staticmethod(untwisted.each(lambda: equal('\r\n'.join((
'Received: from example.com (localhost [127.0.0.1])',
' by example.com (Postfix) with ESMTPA',
' for <notBob@example.com>; Fri, 13 Feb 2009 15:31:30 -0800 (PST)',
'From: <abc123@nottheoilrig.com>',
'',
'Expect')), (yield))))
ctx = yield sample.__get__(ctx)()
# QUIT
yield smtp.server.mail.__get__(ctx)()
#@...
@untwisted.identity(connect().then)
class client(smtp.client):
@untwisted.each
def mail():
ctx = yield
class sample(smtp.client.mail):
sender = iter(('alice@example.com',)).next
recipient = iter(('bob@example.com',)).next
content = iter(('\r\n'.join((
'Received: from example.com (localhost [127.0.0.1])',
' by example.com (Postfix) with ESMTPA',
' for <notBob@example.com>; Fri, 13 Feb 2009 15:31:30 -0800 (PST)',
'From: <notAlice@example.com>',
'',
'Expect')),)).next
yield sample.__get__(ctx)()
return client