[Mailman-Users] Writing a custom handler

Mark Sapiro mark at msapiro.net
Wed Jul 3 02:23:54 CEST 2013


On 07/02/2013 03:09 PM, Chris Nulk wrote:
> 
> Thank you for the help.   Hopefully a last question.  In the
> do_discard_globalban function, how can I send the discard message to
> mailman list?  Or should I?  As it stands now, each list owner/admin
> would be getting the message for their list.  I am thinking that as the
> site administrator and maintainer of the global ban list, I should also
> get the message.


See below.


> In the updated code, I did change the populating of the banlist in the
> Read_GlobalBan_File function.  Now, it strips and lowercases the
> addresses before it checks if the address is in the banlist. Before, it
> checked then populated a stripped, lowercase version. This could have
> resulted in duplicates if the address in the banlist but the address
> checked had a different case profile.


See below.


>     # Go through possible senders.  Check if any of them are
>     #   on the global ban list
>     for sender in msg.get_senders():
>         if sender.lower() in banlist:


Not necessary to lowercase sender here as msg.get_senders() always
returns lowercased addresses unless called with a preserve_case argument
with a True value.


> # copied almost verbatim from Mailman/Handlers/Moderate.py
> def do_discard_globalban(mlist, msg, sender):
>     # forward auto-discards to list owners?
>     if mlist.forward_auto_discards:


Note that no forwarding of the discard occurs unless the list's Privacy
options... -> Sender filters -> forward_auto_discards is set to Yes.
Otherwise, no notice is sent and the only indication is a "Message
discarded, msgid: ..." entry in the 'vette' log.

You may wish to remove the above condition.


>         lang = mlist.preferred_language
>         nmsg = Message.UserNotification(mlist.GetOwnerEmail(),


mlist.GetOwnerEmail() returns the LISTNAME-owner address which is the
recipient of this mail. This argument can be a string with a single
address as it's value as it is here or a list of strings, each of which
is an address. So the above line could be changed to

        nmsg = Message.UserNotification([
                                         mlist.GetOwnerEmail(),
                                         'you at example.com',
                                         ],

with whatever list of addresses you want, or maybe since list owners
aren't much involved with this ban list

        nmsg = Message.UserNotification('you at example.com',


>                                         mlist.GetBouncesEmail(),
>                                         _('Global Ban List Auto-discard
> notification'),
>                                         lang=lang)

-- 
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