From 6e33a67a8cb5011081e4dfb78b3082dd86ce8886 Mon Sep 17 00:00:00 2001 From: yvesf Date: Sat, 20 Feb 2010 22:50:36 +0100 Subject: mhonarc, maildir 2 rss --- convert.sh | 2 + maildir2rss.py | 37 ++++++++++++++++ mhonarc.mrc | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ smtp.py | 12 +++++- 4 files changed, 181 insertions(+), 1 deletion(-) create mode 100755 convert.sh create mode 100644 maildir2rss.py create mode 100644 mhonarc.mrc diff --git a/convert.sh b/convert.sh new file mode 100755 index 0000000..6e79cfa --- /dev/null +++ b/convert.sh @@ -0,0 +1,2 @@ +#!/bin/sh +mhonarc -rcfile "`dirname "$0"`/mhonarc.mrc" -outdir "$1" "`dirname "$0"`/Maildir/cur" "`dirname "$0"`/Maildir/new" diff --git a/maildir2rss.py b/maildir2rss.py new file mode 100644 index 0000000..563a48f --- /dev/null +++ b/maildir2rss.py @@ -0,0 +1,37 @@ +import datetime +import PyRSS2Gen +from mailbox import Maildir +import os,sys + +maildir=Maildir(os.path.dirname(os.path.abspath(__file__)) + "/Maildir") + +items=[] +for key in maildir.keys(): + msg = maildir[key] + try: + subject = msg['subject'] + author=msg['from'] + msg.rewindbody() + description = msg.fp.read() + rfcdate = msg.getdate('date') + date=datetime.datetime(*rfcdate[:-2]) + item=PyRSS2Gen.RSSItem( + title=subject, + author=author, + link="http://xapek.org", + description=description, + pubDate=date + ) + items.append(item) + sys.stderr.write( "processed %s\n" % key) + except Exception,e: + sys.stderr.write("skip %s: %s\n" % (key,str(e))) + +rss = PyRSS2Gen.RSS2( + title = "Spamfeed", + link = "http://www.xapek.org/~yvesf/spam", + description = "Spam spam spam", + lastBuildDate = datetime.datetime.now(), + items=items +) +rss.write_xml(sys.stdout) diff --git a/mhonarc.mrc b/mhonarc.mrc new file mode 100644 index 0000000..a592be7 --- /dev/null +++ b/mhonarc.mrc @@ -0,0 +1,131 @@ + + + + +index.html + + + + + + + + + +20 + + + + + + + +$IDXTITLE$ + + + +RSS Feed +

$IDXTITLE$

+
+ + + + + + +$TIDXTITLE$ + + + +RSS Feed +

$TIDXTITLE$

+
+ + + + + + + + + +
Page $PAGENUM$ of $NUMOFPAGES$ +
$PGLINK(PREV)$ +[First Page] +[Last Page] +$PGLINK(NEXT)$ +
+
+
    + + + + + + + + + + +
    Page $PAGENUM$ of $NUMOFPAGES$ +
    $PGLINK(TPREV)$ +[First Page] +[Last Page] +$PGLINK(TNEXT)$ +
    +
    +
      + + + + + + + + + + +to +from +date +reply-to + + + + +Mailing List Archive (by Date) + + + + +Mailing List Archive (Threaded) + + + + +
    • $SUBJECT$ - + $YYYYMMDD$ - $FROMNAME$ +
    • +
      + + + +
    • $SUBJECT$ - + $FROMNAME$ + + + + +text/plain;maxwidth=80 + + + + +^[^\.] + diff --git a/smtp.py b/smtp.py index 96fd830..c23917b 100644 --- a/smtp.py +++ b/smtp.py @@ -24,10 +24,20 @@ class SMTPChannel(asynchat.async_chat): self.server.logger.debug("Write: " + data) asynchat.async_chat.push(self,data) + def handle_close(self): + asynchat.async_chat.handle_close(self) + if self.read_data and len(self.data) > 10: + #QUIT oder "." wurde nicht erkannt + mail = email.message_from_string(self.data) + key=self.server.maildir.add(mail) + self.server.logger.info("New Mail: %s" % key) + self.server.maildir.flush() + + def found_terminator(self): try: if self.read_data: - if self.data.endswith(".") or self.data.endswith(".\r"): + if self.data.endswith("\n.") or self.data.endswith("\n.\r"): self.read_data = False self.push("250 Ok: queued as 12345\n") mail = email.message_from_string(self.data) -- cgit v1.2.1