[Mailman-Users] How to enforce Author line?
Mark Sapiro
mark at msapiro.net
Fri May 28 01:01:13 CEST 2010
Robert Khachikyan wrote:
>
>On some of the lists, I want to configure such that the very first line
>of the body contains the "Author: <name here>" line.
>
>(This is for legacy purposes). And if the Author line is not given,
>then messages are bounced to moderator and/or the sender.
>
>I tried putting ^Author: and other reg exps in the "topics" section, but
>none worked.
For the most part, Mailman only has facilities for examining message
headers and not body contents. There are a few cases such as an
Approved: header for message pre-approval or a Subject: or Keywords:
header for topics where Mailman also will look at the initial body
lines for a match, but in the case of Topics, it still only looks in
the body for lines that look like a Subject: or Keywords: header.
Thus, if you were going to use topic filters for this the initial body
line would need to be
Subject: Author: ...
or
Keywords: Author: ...
The way to do what you want is with a custom handler. See the FAQ at
<http://wiki.list.org/x/l4A9> for information on installing a custom
handler. You can apply one of the methods for installing for a single
list to each of the lists you want to use it for.
The handler code itself could look something like the following:
from Mailman import Errors
class NoAuthorLine(Errors.HoldMessage):
reason = 'No Author line in the message body'
rejection = "The first text/plain part of the message didn't begin
with Author:"
def process(mlist, msg, msgdata):
for part in msg.walk():
if part.get_content_type <> 'text/plain':
continue
if part.get_payload(decode=True).startswith('Author:')
return
else:
raise NoAuthorLine
raise NoAuthorLine
(watch out for the wrapped rejection = line above, and this is untested)
If this handler were in the pipeline, say ahead of Moderate, any
message that didn't have a text/plain part or whose first text/plain
part didn't start with 'Author:' would be held for approval for 'No
Author line in the message body' and if rejected by the moderator, the
default reason would be "The first text/plain part of the message
didn't begin with Author:"
If the message's first text/plain part did begin with Author:, it would
pass this check but still be subject to membership and moderation
tests and miscellaneous holds.
If you wanted to apply the membership and moderation and
*_these_nonmembers tests first but not the miscellaneous holds, put
the handler in the pipeline between Moderate and Hold.
--
Mark Sapiro <mark at msapiro.net> The highway is for gamblers,
San Francisco Bay Area, California better use your sense - B. Dylan
More information about the Mailman-Users
mailing list