diff options
-rwxr-xr-x | convert.sh | 2 | ||||
-rw-r--r-- | maildir2rss.py | 37 | ||||
-rw-r--r-- | mhonarc.mrc | 131 | ||||
-rw-r--r-- | smtp.py | 12 |
4 files changed, 181 insertions, 1 deletions
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 @@ +<!-- MHonArc Resource File --> +<!-- 28 Jun 2000 Joe Gray - /home/mailman/mhonarc.mrc --> +<!-- Set the main archive HTML page name. --> +<IDXFNAME> +index.html +</IDXFNAME> + +<!-- Don't save resources in database since we invoke with resource file. --> +<NOSAVERESOURCES> + +<!-- Break index into multiple pages with 20 messages per page. --> +<MULTIPG> + +<IDXSIZE> +20 +</IDXSIZE> + +<!-- add RSS link--> +<IdxPgBegin> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" + "http://www.w3.org/TR/html4/loose.dtd"> +<html> +<head> +<title>$IDXTITLE$</title> +<link rel="alternate" type="application/rss+xml" title="Spam RSS Feed" href="spam.rss" /> +</head> +<body> +<a href="spam.rss" title="RSS feed">RSS Feed</a> +<h1>$IDXTITLE$</h1> +</IdxPgBegin> + +<!-- add RSS link--> +<TIdxPgBegin> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" + "http://www.w3.org/TR/html4/loose.dtd"> +<html> +<head> +<title>$TIDXTITLE$</title> +<link rel="alternate" type="application/rss+xml" title="Spam RSS Feed" href="spam.rss" /> +</head> +<body> +<a href="spam.rss" title="RSS feed">RSS Feed</a> +<h1>$TIDXTITLE$</h1> +</TIdxPgBegin> + +<!-- Since MULTIPG is on, add more navigation links to Main index page. --> +<ListBegin> +<ul> +<li><a href="$TIDXFNAME$">Thread Index</a></li> +</ul> +<table width="100%" border=0 cols=2 cellpadding=0 cellspacing=0> +<tbody> +<tr align="center"> +<th colspan=4>Page $PAGENUM$ of $NUMOFPAGES$ +<tr> +<td align="left">$PGLINK(PREV)$ +<td align="right">[<a href="$PG(FIRST)$">First Page</a>] +<td align="left">[<a href="$PG(LAST)$">Last Page</a>] +<td align="right">$PGLINK(NEXT)$ +</tbody> +</table> +<hr> +<ul> +</ListBegin> + +<!-- Since MULTIPG is on, add more navigation links to Threaded index page. --> +<THead> +<ul> +<li><a href="$IDXFNAME$">Date Index</a></li> +</ul> +<table width="100%" border=0 cols=2 cellpadding=0 cellspacing=0> +<tbody> +<tr align="center"> +<th colspan=4>Page $PAGENUM$ of $NUMOFPAGES$ +<tr> +<td align="left">$PGLINK(TPREV)$ +<td align="right">[<a href="$PG(TFIRST)$">First Page</a>] +<td align="left">[<a href="$PG(TLAST)$">Last Page</a>] +<td align="right">$PGLINK(TNEXT)$ +</tbody> +</table> +<hr> +<ul> +</THead> + +<!-- Specify date sorting. --> +<Sort> + +<!-- Set mod time of the HTML message to the time the message was sent. --> +<MODTIME> + +<!-- Show only these fields in the message header. --> +<FieldOrder> +to +from +date +reply-to +</FieldOrder> + +<!-- Change main index title to reflect date sorting. --> +<TITLE> +Mailing List Archive (by Date) +</TITLE> + +<!-- Change threaded index title to reflect threading. --> +<TTITLE> +Mailing List Archive (Threaded) +</TTITLE> + +<!-- Change format of Date Index listing. --> +<LiTemplate> +<li><strong>$SUBJECT$</strong> - +<em> $YYYYMMDD$ - $FROMNAME$</em> +</li> +</LiTemplate> + +<!-- Change format of Thread Index listing. --> +<TLiTxt> +<li><strong>$SUBJECT$</strong> - +<em> $FROMNAME$</em> +</TLiTxt> + +<!-- Force plain text messages to wordwrap. --> +<MIMEargs> +text/plain;maxwidth=80 +</MIMEargs> + + +<MHPATTERN> +^[^\.] +</MHPATTERN> @@ -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) |