FAQ
Hi All,

I've only recently discovered the world of regexps, so please bare with
me. What I want to do is block messages whose subject starts with "[SPAM".

Mail to my server goes through spamassassin first - it alters mail that
it thinks is spam by adding [SPAM xx.xx] to the start of the subject.
What I'd like to do is get mailman to just automatically drop these
messages.

An example subject is something like this:

Subject: [SPAM 07.49] Stop your computer from crashing, guaranteed!

(btw, I've just copied and pasted this from mailmans administratrive
requests page - there is a tab b/w the colon and the [ open bracket).

Here are the different regexp's that I've tried, none seem to work.

subject: .*\[SPAM*
subject:.*\[SPAM*
subject: .*[SPAM*
subject:.*[SPAM*

subject:*\[SPAM*
subject: *\[SPAM*
subject:\[SPAM*
subject: \[SPAM*

subject: [SPAM*
subject: *[SPAM*
subject:[SPAM*
subject:*[SPAM*

what am I doing wrong??

TIA

David

Search Discussions

  • Stephen J. Turnbull at May 31, 2005 at 1:19 am
    "David" == David Powell <(YANQ)" <tech at yanq.org.au>> writes:
    Life will be much easier for this kind of task if you upgrade to
    Mailman 2.1.x; 2.1.6 is current.

    David> Here are the different regexp's that I've tried, none seem
    David> to work.

    Really, you should invest in Jeffrey Friedl's book, _Mastering Regular
    Expressions_. I'm sure there are many on-line tutorials, too. This
    is not the channel for questions that arise because you don't
    understand how to construct a regular expression. For now, try

    subject:[ \t]*\[SPAM
    subject:[ \t]*\\[SPAM

    I forget offhand whether Mailman treats the strings it reads as "raw
    strings" or as regular strings. If the former, the first regexp is
    the one that should work. If the latter, the second will work.

    --
    School of Systems and Information Engineering http://turnbull.sk.tsukuba.ac.jp
    University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
    Ask not how you can "do" free software business;
    ask what your business can "do for" free software.
  • David Powell at May 31, 2005 at 5:44 am
    Thanks for the help, to respond...
    Life will be much easier for this kind of task if you upgrade to
    Mailman 2.1.x; 2.1.6 is current.
    Agreed - I don't administer the server, but understand we're waiting for
    the new stable release of Debian (any day now).
    Really, you should invest in Jeffrey Friedl's book, _Mastering Regular
    Expressions_. I'm sure there are many on-line tutorials, too. This
    is not the channel for questions that arise because you don't
    understand how to construct a regular expression. For now, try

    subject:[ \t]*\[SPAM
    subject:[ \t]*\\[SPAM
    Neither of these worked. I'll take a look at that book though, ta.
    Also I understand that this isn't a regexp help list, and sorry if I've
    wasted some bandwidth.

    However, in my defence, prior to posting I did look at quite a few
    online tutorials, and then tested out a few expressions on some text
    files. When I found a few expressions that worked I used these in
    mailman(without luck obviously).

    Following Stephen's suggestions, I've tried a few more. What I did was
    place the following lines (among others) in a text file. As I'm not
    sure exactly how the subject header is formatted, I wanted something
    that would find all off the following:

    subject: [SPAM 07.49] Stop your computer from crashing
    subject: [SPAM 07.49] Stop your computer from crashing
    subject:[SPAM 07.49] Stop your computer from crashing
    Subject: [SPAM 07.49] Stop your computer from crashing
    Subject: [SPAM 07.49] Stop your computer from crashing
    Subject:[SPAM 07.49] Stop your computer from crashing

    One line has a tab b/w ":" and "[SPAM", another a space and the third
    nothing. The other thing I wasn't sure about was if the first letter of
    subject is uppper case or not.

    The expression I found that matched all 6 lines (using grep) was:
    [sS]ubject:.*\[SPAM

    I also used the find function in KATE, and found that it preferred:
    [sS]ubject:[\s]*\[SPAM

    (using [\t] didn't match the lines with a tab)

    Neither of these worked in mailman, so I tried with just upper, then
    lowercase 's' to start with (i.e. subject:.*\[SPAM and Subject:/* etc ).

    This hasn't worked either. So I guess I'm at a loss. I've got my head
    around regular expressions enough to find what I want in a text file,
    but can't get it work in Mailman.

    Am I dumber than I think (very possible ;->) or is there something about
    the way that Mailman handles regexps that I've missed?

    Ta,

    David
  • Jim Tittsler at May 31, 2005 at 6:56 am

    On May 31, 2005, at 14:44, David Powell wrote:

    One line has a tab b/w ":" and "[SPAM", another a space and the third
    nothing. The other thing I wasn't sure about was if the first
    letter of
    subject is uppper case or not.
    If you are putting these in 2.0.x's bounce_matching_headers list
    variable, it doesn't matter. Mailman takes the thing before the
    colon and its trailing whitespace (tabs or spaces) as the header
    field name to look for and the remainder of the line as the regular
    expression to compare against. (Which explains the comment in the
    description that unescaped leading whitespace is stripped from the
    regex... not that it affects your case.)

    (For the test cases where you didn't have whitespace separating the
    subject: and the regex, I'm surprised that you didn't get error
    messages logged in your Mailman config log.)

    subject: \[SPAM
    worked for me on an old 2.0.13 Mailman. (I don't have a 2.0.11
    version to play with, but a really quick check of the CVS log
    suggests there were no relevant changes between those versions.) If
    you want to track down where its going wrong on your machine, you
    could sprinkle some syslog() calls in Mailman/MailList.py's
    parse_matching_header_opt() and HasMatchingHeader().

    --
    Jim Tittsler http://www.OnJapan.net/ GPG: 0x01159DB6
    Python Starship http://Starship.Python.net/crew/jwt/
    Mailman IRC irc://irc.freenode.net/#mailman

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupmailman-users @
categoriespython
postedMay 30, '05 at 10:58p
activeMay 31, '05 at 6:56a
posts4
users3
websitelist.org

People

Translate

site design / logo © 2022 Grokbase