procmail replacement in Python
gh_pythonlist at gmx.de
Wed Jun 19 02:16:01 CEST 2002
* Sean 'Shaleh' Perry <shalehperry at attbi.com> [2002-06-18 17:04 -0700]:
> On 18-Jun-2002 Gerhard Häring wrote:
> > Does such a thing exist?
> there is also a nice filter language from CMU called Sieve (I think). You
> could implement a python based Sieve interpreter.
I'd just switch to Cyrus IMAP instead. I'm currently using Courier IMAP
and am quite satisfied, so I have little reason to switch. I even found
Cyrus difficult to install, even though it's also available as a FreeBSD
package (just like Courier).
All that I'm currently using from procmail are regexes on header fields,
combined with AND, and maybe OR conditions. And having two custom
filters before matching the header fields:
- this one to fight stupidity in the setup of the German freemailer GMX:
they have some braindead software that does mbox-like From_ quoting on
their POP3 setup :-(
import re, sys
BROKEN_FROM = re.compile(r"^(>+)(from )(.*)", re.I | re.DOTALL)
for line in sys.stdin.xreadlines():
match = BROKEN_FROM.match(line)
if not match:
# Remove one quote char added by braindead GMX software
groups = match.groups()
escape_chars = groups[:-1]
sys.stdout.write(escape_chars + groups + groups)
This sig powered by Python!
Außentemperatur in München: 23.1 °C Wind: 0.9 m/s
More information about the Python-list