/
addMessageId
executable file
·61 lines (47 loc) · 1.88 KB
/
addMessageId
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
59
60
61
#!/usr/bin/env python
from cookie.test import *
from untwisted import smtp
expect(4)
@sdfg
def _():
for cursor in conn:
cursor.execute('INSERT INTO address (address, sender) VALUES (%s, %s)', 'bob@example.com', 'abc123')
#@listen().then
@untwisted.identity(listen().then)
class _(smtp.server):
@untwisted.each
def mail():
ctx = yield
class sample(smtp.server.mail):
sender = staticmethod(untwisted.each(lambda: equal('alice@example.com', str((yield)))))
recipient = staticmethod(untwisted.each(lambda: equal('abc123@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 ESMTP',
' for <abc123@example.com>; Fri, 13 Feb 2009 15:31:30 -0800 (PST)',
'From: notalice@example.com',
'Message-ID: <1234567890@example.com>',
'',
'la di da')), (yield))))
ctx = yield sample.__get__(ctx)()
# QUIT
yield smtp.server.mail.__get__(ctx)()
#@connect().then
@untwisted.identity(connect().then)
class _(smtp.client):
@untwisted.each
def mail():
ctx = yield
class sample(smtp.client.mail):
sender = iter(('alice@example.com',)).next
recipient = iter(('abc123@example.com',)).next
content = iter(('\r\n'.join(('Received: from example.com (localhost [127.0.0.1])',
' by example.com (Postfix) with ESMTP',
' for <abc123@example.com>; Fri, 13 Feb 2009 15:31:30 -0800 (PST)',
'From: notalice@example.com',
'Message-ID: <1234567890@example.com>',
'',
'la di da')),)).next
yield sample.__get__(ctx)()
yield _
for cursor in conn:
equiv((('abc123',),), cursor.execute('SELECT sender FROM message_id WHERE message_id = %s', '1234567890@example.com'))