On Thursday 05 September 2002 09:49 am, Odhiambo Washington wrote:
> * G. Armour Van Horn <[EMAIL PROTECTED]> [20020905 19:45]: wrote:
> > There is no way to automatically discard the messages that come to the
> > list
>
> I may be wrong but if you search the archives of this list for "clear
> requests", someone did contribute a script that can be run via cron to
> discard the messages.

Works for me.

Irwin

Here is the cron line:

45 16 * * * /usr/bin/python2.1 -S /var/mailman/cron/clear-requests listname

Here is the script:

#! /usr/bin/env python

# We can use this and run it differently from the others - !/usr/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()

------------------------------------------------------
Mailman-Users mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://www.python.org/cgi-bin/faqw-mm.py
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/

Reply via email to