diff options
| author | Barry Warsaw | 2009-01-25 13:01:41 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2009-01-25 13:01:41 -0500 |
| commit | eefd06f1b88b8ecbb23a9013cd223b72ca85c20d (patch) | |
| tree | 72c947fe16fce0e07e996ee74020b26585d7e846 /mailman/rules/docs/header-matching.txt | |
| parent | 07871212f74498abd56bef3919bf3e029eb8b930 (diff) | |
| download | mailman-eefd06f1b88b8ecbb23a9013cd223b72ca85c20d.tar.gz mailman-eefd06f1b88b8ecbb23a9013cd223b72ca85c20d.tar.zst mailman-eefd06f1b88b8ecbb23a9013cd223b72ca85c20d.zip | |
Diffstat (limited to 'mailman/rules/docs/header-matching.txt')
| -rw-r--r-- | mailman/rules/docs/header-matching.txt | 144 |
1 files changed, 0 insertions, 144 deletions
diff --git a/mailman/rules/docs/header-matching.txt b/mailman/rules/docs/header-matching.txt deleted file mode 100644 index 417000d67..000000000 --- a/mailman/rules/docs/header-matching.txt +++ /dev/null @@ -1,144 +0,0 @@ -Header matching -=============== - -Mailman can do pattern based header matching during its normal rule -processing. There is a set of site-wide default header matches specified in -the configuration file under the [spam.headers] section. - - >>> from mailman.app.lifecycle import create_list - >>> mlist = create_list(u'_xtest@example.com') - -Because the default [spam.headers] section is empty, we'll just extend the -current header matching chain with a pattern that matches 4 or more stars, -discarding the message if it hits. - - >>> chain = config.chains['header-match'] - >>> chain.extend('x-spam-score', '[*]{4,}', 'discard') - -First, if the message has no X-Spam-Score header, the message passes through -the chain untouched (i.e. no disposition). - - >>> msg = message_from_string("""\ - ... From: aperson@example.com - ... To: _xtest@example.com - ... Subject: Not spam - ... Message-ID: <one> - ... - ... This is a message. - ... """) - - >>> from mailman.core.chains import process - -Pass through is seen as nothing being in the log file after processing. - - # XXX This checks the vette log file because there is no other evidence - # that this chain has done anything. - >>> import os - >>> fp = open(os.path.join(config.LOG_DIR, 'vette')) - >>> fp.seek(0, 2) - >>> file_pos = fp.tell() - >>> process(mlist, msg, {}, 'header-match') - >>> fp.seek(file_pos) - >>> print 'LOG:', fp.read() - LOG: - <BLANKLINE> - -Now, if the header exists but does not match, then it also passes through -untouched. - - >>> msg['X-Spam-Score'] = '***' - >>> del msg['subject'] - >>> msg['Subject'] = 'This is almost spam' - >>> del msg['message-id'] - >>> msg['Message-ID'] = '<two>' - >>> file_pos = fp.tell() - >>> process(mlist, msg, {}, 'header-match') - >>> fp.seek(file_pos) - >>> print 'LOG:', fp.read() - LOG: - <BLANKLINE> - -But now if the header matches, then the message gets discarded. - - >>> del msg['x-spam-score'] - >>> msg['X-Spam-Score'] = '****' - >>> del msg['subject'] - >>> msg['Subject'] = 'This is spam, but barely' - >>> del msg['message-id'] - >>> msg['Message-ID'] = '<three>' - >>> file_pos = fp.tell() - >>> process(mlist, msg, {}, 'header-match') - >>> fp.seek(file_pos) - >>> print 'LOG:', fp.read() - LOG: ... DISCARD: <three> - <BLANKLINE> - -For kicks, let's show a message that's really spammy. - - >>> del msg['x-spam-score'] - >>> msg['X-Spam-Score'] = '**********' - >>> del msg['subject'] - >>> msg['Subject'] = 'This is really spammy' - >>> del msg['message-id'] - >>> msg['Message-ID'] = '<four>' - >>> file_pos = fp.tell() - >>> process(mlist, msg, {}, 'header-match') - >>> fp.seek(file_pos) - >>> print 'LOG:', fp.read() - LOG: ... DISCARD: <four> - <BLANKLINE> - -Flush out the extended header matching rules. - - >>> chain.flush() - - -List-specific header matching ------------------------------ - -Each mailing list can also be configured with a set of header matching regular -expression rules. These are used to impose list-specific header filtering -with the same semantics as the global [spam.headers] section. - -The list administrator wants to match not on four stars, but on three plus -signs, but only for the current mailing list. - - >>> mlist.header_matches = [('x-spam-score', '[+]{3,}', 'discard')] - -A message with a spam score of two pluses does not match. - - >>> del msg['x-spam-score'] - >>> msg['X-Spam-Score'] = '++' - >>> del msg['message-id'] - >>> msg['Message-ID'] = '<five>' - >>> file_pos = fp.tell() - >>> process(mlist, msg, {}, 'header-match') - >>> fp.seek(file_pos) - >>> print 'LOG:', fp.read() - LOG: - -A message with a spam score of three pluses does match. - - >>> del msg['x-spam-score'] - >>> msg['X-Spam-Score'] = '+++' - >>> del msg['message-id'] - >>> msg['Message-ID'] = '<six>' - >>> file_pos = fp.tell() - >>> process(mlist, msg, {}, 'header-match') - >>> fp.seek(file_pos) - >>> print 'LOG:', fp.read() - LOG: ... DISCARD: <six> - <BLANKLINE> - -As does a message with a spam score of four pluses. - - >>> del msg['x-spam-score'] - >>> msg['X-Spam-Score'] = '+++' - >>> del msg['message-id'] - >>> msg['Message-ID'] = '<seven>' - >>> file_pos = fp.tell() - >>> process(mlist, msg, {}, 'header-match') - >>> fp.seek(file_pos) - >>> print 'LOG:', fp.read() - LOG: ... DISCARD: <seven> - <BLANKLINE> |
