dhanushka ranasinghe wrote:
>
>is it possible  to  filter and reject any mails that have certain words in  
>them


Yes, it is but it requires a custom handler to examine the message body
and take appropriate action. See the FAQ at
<http://wiki.list.org/x/l4A9>

The handler you want is fairly simple. A basic outline is


import re
from Mailman import Errors
from Mailman import Utils

# Compile re to match words with flags like IGNORECASE, etc as desired.
CRE = re.compile('re_that_matches_your_words', re.IGNORCASE)
# Rejection message if we're rejecting.
MESSAGE = Utils.wrap("""Some nice message as to why
the message is being rejected.""")

def process(mlist, msg, msgdata):
    for part in msg.walk():
        if part.get_content_maintype() == 'text':
            if CRE.search(part.get_payload(decode=True)):
                raise Errors.RejectMessage , MESSAGE
                # or raise Errors.DiscardMessage if you want to
                # just discard it.


-- 
Mark Sapiro <m...@msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan

------------------------------------------------------
Mailman-Users mailing list Mailman-Users@python.org
http://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Security Policy: http://wiki.list.org/x/QIA9
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-users/archive%40jab.org

Reply via email to