[Mailman-Users] Automatically reject - how?

Odhiambo Washington wash at wananchi.com
Thu Aug 22 19:00:30 CEST 2002


* Borries Demeler <demeler at bioc09.v19.uthscsa.edu> [20020822 19:45]: wrote:
> Hi,
> 
> I was wondering how I could set up mailman so I am not always required
> to manually delete or reject messages held for approval. I have mailing
> lists set up such that subscribers are allowed to post, non-subscribers
> are not. I monitor who subscribes. If a spammer posts, it should be 
> automatically rejected. Now I have to do this manually. Any suggestions
> on how to accomplish this?


Search ther archives for "clear-requests" or.... lemme make life easier ;-)

Add this line to mailman's cron:

# Clear all unsub requests at 16.45
45 16 * * * /usr/local/bin/python2.2 -S /usr/local/mailman/cron/clear-requests listname

substitute "listname" with your list name.

The clear-requests is attached. Credit belongs to the person who wrote it, not me.

If you want explanation as to why it is run at that time, search the list archives.
I got it from there.


HTH


-Wash

-- 
Odhiambo Washington   <wash at wananchi.com>  "The box said 'Requires
Wananchi Online Ltd.  www.wananchi.com      Windows 95, NT, or better,'
Tel: +254 2 313985-9  +254 2 313922         so I installed FreeBSD."   
GSM: +254 72 743223   +254 733 744121       This sig is McQ!  :-)


If you think the United States has stood still, who built the largest
shopping center in the world?
		-- Richard Nixon
-------------- next part --------------
#! /usr/bin/env python

# We can use this and run it differently from the others - !/usr/local/bin/python

# I configured a list to accept messages from subscribers only
# so that unsubscribers' messages can be approved by admin manually.
# But these days some spammers started to send too many messages
# so deleting those messages takes quite time.
#
# Is there any way to configure mailman delete every messages
# from unsubscribers automatically and do not even notify it
# to the list admin?

# I use this script to do just that. Name it (clear_request) and put it in
# mailman cronjob.

# The default cron job for mailman most likely mails admins at 5pm about
# pending requests so you should run this script at 4:50pm or something.


# Written by Donal Hunt
# April 23rd 2001
#
# argv[1] should be the name of the list.

"""Clear pending administrative requests for a list

Usage:
    clear_requests listname

Where:

    listname
        The name of the Mailman list you want to clear
        pending requests from.  It must already exist.

"""

import sys
import os
import string
import getopt
import paths
from Mailman import mm_cfg
from Mailman import Utils
from Mailman import MailList
from Mailman import Errors
from Mailman import Message
from Mailman.Logging.Syslog import syslog


def usage(status, msg=''):
    if msg:
        print msg
    print __doc__ % globals()
    sys.exit(status)


def main():
    try:
        ml = MailList.MailList(sys.argv[1])
    except Errors.MMListError, e:
        usage(1, 'No such list: %s (%s)' % (listname, e))
    try:
        print 'No of Requests Pending: %s ' % ml.NumRequestsPending()
        print 'No of postings awaiting approval: %s ' % ml.GetHeldMessageIds()
        print 'No of subsciptions awaiting approval: %s ' % ml.GetSubscriptionIds()
        for i in ml.GetHeldMessageIds():
            ml.HandleRequest(i, 3)
        for i in ml.GetSubscriptionIds():
            ml.HandleRequest(i, 2, 'No subscription allowed - please mail %s' % ml.owner[0] )

        print 'No of Requests Pending: %s ' % ml.NumRequestsPending()
        ml.Save()
    finally:
        ml.Unlock()

main()


More information about the Mailman-Users mailing list