1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import asyncore, smtpd, threading
21
22 from pysys.constants import *
23
24
26 - def __init__(self, localaddr, remoteaddr, filename='smtpserver.out', logMails=True):
27 smtpd.SMTPServer.__init__(self, localaddr, remoteaddr)
28 try:
29 self.fp = open(filename, 'w')
30 self.logMails = logMails
31 self.count = 0
32 except:
33 pass
34
36 self.count = self.count + 1
37 if self.fp:
38 self.fp.write("SimpleSMTPServer: Message count = %d\n" % self.count)
39 if self.logMails: self.fp.write(data)
40 self.fp.flush()
41
42
46
48 while not self.exit:
49 asyncore.loop(timeout=1.0, use_poll=False, count=1)
50
53
56