1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#!/usr/bin/env python
import sys, os, mailbox, email, smtpd, asyncore
class MaildirServer(smtpd.PureProxy):
def __init__(self, localaddr, remoteaddr):
smtpd.SMTPServer.__init__(self, localaddr, remoteaddr)
self.maildir = mailbox.Maildir("./Maildir", create=True)
def _deliver(self, mailfrom, rcpttos, data):
mail = email.message_from_string(data)
maildirMail = Message(mail)
self.maildir.add(maildirMail)
if __name__ == '__main__':
muttrc = os.path.join(os.path.dirname(__file__), "muttrc")
print("Use `mutt -F {}' to read mails".format(muttrc))
smtpd.DEBUGSTREAM = sys.stderr
server = MaildirServer(("0.0.0.0", 8025), (None, None))
asyncore.loop()
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
|