--- Begin Message ---
- To: Debian Bug Tracking System <submit@bugs.debian.org>
- Subject: mailping: patch to add support for subject prefix
- From: Serafeim Zanikolas <sez@debian.org>
- Date: Mon, 27 Jun 2011 23:27:01 +0200
- Message-id: <20110627212701.611.35836.reportbug@mobee>
Package: mailping
Version: 0.0.4-2
Severity: wishlist
Tags: patch
Hi,
Please consider adopting the attached patch to avoid the classification of
mailping emails as junk when the email subject gets a prefix (eg. as is
commonly the case when an email goes through a mailing list).
This optional feature can be configured using the subject-prefix file in the
circuit directory.
Cheers,
Serafeim
-- System Information:
Debian Release: wheezy/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.38-2-686 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages mailping depends on:
ii adduser 3.112+nmu2 add and remove users and groups
ii munin-node 1.4.5-3 network-wide graphing framework (n
ii python 2.6.6-14 interactive high-level object-orie
ii python-support 1.0.13 automated rebuilding support for P
mailping recommends no packages.
mailping suggests no packages.
-- no debconf information
diff -Nurp mailping-0.0.4.orig//bin/mailping-cron mailping-0.0.4/bin/mailping-cron
--- mailping-0.0.4.orig//bin/mailping-cron 2004-04-16 17:47:36.000000000 +0200
+++ mailping-0.0.4/bin/mailping-cron 2011-06-04 17:15:54.000000000 +0200
@@ -37,6 +37,7 @@ def main():
fromAddress = config.getEmail(configPath, 'from', None)
toAddress = config.getEmail(configPath, 'to', None)
+ subjectPrefix = config.getSubjectPrefix(configPath, 'subject-prefix', '')
if fromAddress is None or toAddress is None:
user = pwd.getpwuid(os.getuid()).pw_name
host = socket.getfqdn()
@@ -49,7 +50,7 @@ def main():
curtime = time.time()
if os.path.isdir(os.path.join(statePath, 'incoming')):
- incoming.process(statePath)
+ incoming.process(statePath, subjectPrefix)
probe.process(statePath, interval, curtime,
fromAddress, toAddress, adminAddress)
diff -Nurp mailping-0.0.4.orig//MailPing/config.py mailping-0.0.4/MailPing/config.py
--- mailping-0.0.4.orig//MailPing/config.py 2004-04-16 19:36:08.000000000 +0200
+++ mailping-0.0.4/MailPing/config.py 2011-06-04 17:15:54.000000000 +0200
@@ -33,6 +33,24 @@ def getEmail(configdir, name, default=_N
l=l.strip()
return l
+def getSubjectPrefix(configdir, name, default=_NoDefault):
+ path = os.path.join(configdir, name)
+ try:
+ f=file(path)
+ except IOError, e:
+ if e.errno == errno.ENOENT:
+ if default is _NoDefault:
+ raise NoSuchConfigItem, name
+ else:
+ return default
+ else:
+ raise
+
+ l=f.readline()
+ l=l.strip()
+ return l
+
+
DEFAULT_CONFIGDIR = '/etc/mailping'
DEFAULT_STATEDIR = '/var/lib/mailping'
diff -Nurp mailping-0.0.4.orig//MailPing/incoming.py mailping-0.0.4/MailPing/incoming.py
--- mailping-0.0.4.orig//MailPing/incoming.py 2011-06-04 17:15:39.000000000 +0200
+++ mailping-0.0.4/MailPing/incoming.py 2011-06-04 17:15:54.000000000 +0200
@@ -1,9 +1,9 @@
import os, shutil
from MailPing import mail, maildir, fileutil
-def process(statedir):
+def process(statedir, subjectPrefix):
def _processEmail(subdir, filename):
- ident = mail.getID(os.path.join(subdir, filename))
+ ident = mail.getID(os.path.join(subdir, filename), subjectPrefix)
if ident is None:
maildir.create(os.path.normpath(os.path.join(subdir, '..', '..', 'junk')))
shutil.move(os.path.join(subdir, filename),
diff -Nurp mailping-0.0.4.orig//MailPing/mail.py mailping-0.0.4/MailPing/mail.py
--- mailping-0.0.4.orig//MailPing/mail.py 2004-04-16 19:26:25.000000000 +0200
+++ mailping-0.0.4/MailPing/mail.py 2011-06-04 17:15:54.000000000 +0200
@@ -1,6 +1,6 @@
from email.Parser import Parser as EmailParser
-def getID(path):
+def getID(path, subjectPrefix=''):
f = file(path)
p = EmailParser()
msg = p.parse(f, True)
@@ -8,8 +8,9 @@ def getID(path):
subj = msg.get('Subject')
if subj is not None:
- if subj.startswith('Mail ping '):
- subj = subj[len('Mail ping '):]
+ pingString = '%sMail ping ' % subjectPrefix
+ if subj.startswith(pingString):
+ subj = subj[len(pingString):]
else:
subj = None
return subj
diff -Nurp mailping-0.0.4.orig//man/mailping-cron.1.xml mailping-0.0.4/man/mailping-cron.1.xml
--- mailping-0.0.4.orig//man/mailping-cron.1.xml 2011-06-04 17:15:39.000000000 +0200
+++ mailping-0.0.4/man/mailping-cron.1.xml 2011-06-04 17:15:54.000000000 +0200
@@ -88,6 +88,12 @@
<filename>to</filename> there, containing the sender and
recipient addresses suitable for the circuit.
</para>
+ <para>
+ If the tested email address goes through a gateway (eg. a mailing list)
+ that adds a prefix to the subject, test emails will be classified as
+ junk. To avoid that, declare the prefix in
+ <filename>subject-prefix</filename> in the circuit directory.
+ </para>
</step>
<step>
--- End Message ---