diff options
| author | Barry Warsaw | 2008-02-27 01:26:18 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2008-02-27 01:26:18 -0500 |
| commit | a1c73f6c305c7f74987d99855ba59d8fa823c253 (patch) | |
| tree | 65696889450862357c9e05c8e9a589f1bdc074ac /Mailman/rules/docs/header-matching.txt | |
| parent | 3f31f8cce369529d177cfb5a7c66346ec1e12130 (diff) | |
| download | mailman-a1c73f6c305c7f74987d99855ba59d8fa823c253.tar.gz mailman-a1c73f6c305c7f74987d99855ba59d8fa823c253.tar.zst mailman-a1c73f6c305c7f74987d99855ba59d8fa823c253.zip | |
Bite the bullet: rename the Mailman package to mailman.
Diffstat (limited to 'Mailman/rules/docs/header-matching.txt')
| -rw-r--r-- | Mailman/rules/docs/header-matching.txt | 145 |
1 files changed, 0 insertions, 145 deletions
diff --git a/Mailman/rules/docs/header-matching.txt b/Mailman/rules/docs/header-matching.txt deleted file mode 100644 index fbd0ff65f..000000000 --- a/Mailman/rules/docs/header-matching.txt +++ /dev/null @@ -1,145 +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 matchines specified in -the configuaration file under the HEADER_MATCHES variable. - - >>> from Mailman.app.lifecycle import create_list - >>> mlist = create_list(u'_xtest@example.com') - -Because the default HEADER_MATCHES variable is empty when the configuration -file is read, we'll just extend the current header matching chain with a -pattern that matches 4 or more stars, discarding the message if it hits. - - >>> from Mailman.configuration import config - >>> 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.app.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 `HEADER_MATCHES` variable. - -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> |
