summaryrefslogtreecommitdiff
path: root/packages/cern-scripts/src/main/resources/bin/smtp-server.py
diff options
context:
space:
mode:
authorYves Fischer <yves.fischer@cern.ch>2016-01-15 19:27:34 +0100
committerYves Fischer <yves.fischer@cern.ch>2016-01-15 19:27:34 +0100
commit23c57ff24840c6f612ffd19effbac70a2c218865 (patch)
tree8d1360d385258599586bf3f9568d77ec8cdb6f92 /packages/cern-scripts/src/main/resources/bin/smtp-server.py
parent3b7cbbd6a5652b055aa680a1fc4dc1369079c78d (diff)
downloaddebian-packages-23c57ff24840c6f612ffd19effbac70a2c218865.tar.gz
debian-packages-23c57ff24840c6f612ffd19effbac70a2c218865.zip
cern-scripts: package
Diffstat (limited to 'packages/cern-scripts/src/main/resources/bin/smtp-server.py')
-rwxr-xr-xpackages/cern-scripts/src/main/resources/bin/smtp-server.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/packages/cern-scripts/src/main/resources/bin/smtp-server.py b/packages/cern-scripts/src/main/resources/bin/smtp-server.py
new file mode 100755
index 0000000..1cfef81
--- /dev/null
+++ b/packages/cern-scripts/src/main/resources/bin/smtp-server.py
@@ -0,0 +1,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