summaryrefslogtreecommitdiff
path: root/packages/cern-scripts/resources/bin/smtp-server.py
diff options
context:
space:
mode:
authorYves Fischer <yvesf@cern.ch>2016-02-01 09:09:31 +0100
committerYves Fischer <yvesf@cern.ch>2016-02-01 09:09:43 +0100
commit3cbe8700c8c6cb1ac41b506681234f995ca979ba (patch)
tree01b6f4e232e23ff9cf5379137a472796784d1abe /packages/cern-scripts/resources/bin/smtp-server.py
parent4de2d5afc7dfdb0409d2ac9359bbe5bac58e2edc (diff)
downloaddebian-packages-3cbe8700c8c6cb1ac41b506681234f995ca979ba.tar.gz
debian-packages-3cbe8700c8c6cb1ac41b506681234f995ca979ba.zip
cern-scripts: restructure source directory
Diffstat (limited to 'packages/cern-scripts/resources/bin/smtp-server.py')
-rwxr-xr-xpackages/cern-scripts/resources/bin/smtp-server.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/packages/cern-scripts/resources/bin/smtp-server.py b/packages/cern-scripts/resources/bin/smtp-server.py
new file mode 100755
index 0000000..1cfef81
--- /dev/null
+++ b/packages/cern-scripts/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