Hi guys
is it possible to filter and reject any mails that have certain words in them
Thank You Dhanushka
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 <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
participants (2)
-
dhanushka ranasinghe
-
Mark Sapiro