Mailman: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
mNo edit summary
Brian Wilson (talk | contribs)
 
(3 intermediate revisions by the same user not shown)
Line 21: Line 21:
== Create a list ==
== Create a list ==


http://hupi.org/cgi-bin/mailman/create
http://hupi.org/mailman/create


== Move a list from a different server ==
== Move a list from a different server ==


== Spam control ==
== Spam control ==
=== Postgrey ===


I am using postgrey (installed from Ubuntu package).
I am using postgrey (installed from Ubuntu package).
Line 35: Line 37:
Postgrey simply sends a message back on first connection refusing email and saying "come back later". It then creates a database (whitelist) entry and if the server connects to try again, lets it through.
Postgrey simply sends a message back on first connection refusing email and saying "come back later". It then creates a database (whitelist) entry and if the server connects to try again, lets it through.


You can whitelist or blacklist anyone manually.
NOQUEUE: reject: RCPT from oproxy2-pub.bluehost.com[67.222.39.60]: 450 4.2.0 <[email protected]>: Recipient address rejected: Greylisted, see http://postgrey.schweikert.ch/help/hupi.org.html; from=<[email protected]> to=<[email protected]> proto=SMTP helo=<oproxy2-pub.bluehost.com>
 
 
You can whitelist anyone manually by editing these files.


  /etc/postgrey/whitelist_clients
  /etc/postgrey/whitelist_clients
  /etc/postgrey/whitelist_recipients
  /etc/postgrey/whitelist_recipients


Local (internal) mail is unaffected.
Databases are in /var/lib/postgrey/
Dump current whitelist database
perl /usr/share/doc/postgrey/postgrey_clients_dump
See also
man postgreyreport
== More anti-spam ==
http://www.fatofthelan.com/technical/how-to-install-postfix-dovecot-amavis-clamav-and-spamassassin-etch/
== Script to mass remove bouncing users ==
Puts a list of commands in /tmp/list that you then run as a script on the mailman server.
<pre>
#!/usr/bin/env python
#
# 1 Read Brian's mailbox
# 2 Build a list of addresses to unsubscribe
# 3 Delete the emails
#
import re
import imaplib
from email.parser import Parser
password = 'xxxxxxxxx'
host = 'imap.googlemail.com'
mailbox = 'Inbox'
port = 993
d_collection = {}
re_mailing_list = re.compile(r'^http://hupi.org/cgi-bin/mailman/options/([^/]+)/(.*)%40(.*)\r')
def process_message(text):
    for line in text.split('\n'):
        mo = re_mailing_list.search(line)
        if mo:
            user = mo.group(2) + '@' + mo.group(3)
            if user in d_collection:
                d_collection[user] += 1
            else:
                d_collection[user] = 1
    return


Local (internal) mail is unaffected.
def read_and_process_mail():
 
    mbox = imaplib.IMAP4_SSL(host,port)
    rc, resp = mbox.login(user, password)
    print rc, resp
    mbox.select(mailbox)
    typ, data = mbox.search(None, 'TO', '[email protected]')
    i = 0
    for num in data[0].split():
        typ, data = mbox.fetch(num, '(BODY[TEXT])')
        process_message(data[0][1])
        print "%d" % i
        i += 1
        mbox.store(num,'+FLAGS', '\\Deleted')
    mbox.expunge()
    mbox.close()
    mbox.logout()


You can monitor the lists
read_and_process_mail()
fp = open('/tmp/list', 'w')
for k in d_collection:
    fp.write(k + "\n")
    print k
fp.close()
</pre>

Latest revision as of 17:25, 14 August 2016

Some tips on using mailman

I am using the standard Ubuntu package. This means things are symlinked from the normal places in /var to where they are really installed in /usr

User.group = list.list not the usual mailman.mailman

Various config files including mm_cfg.py are in /etc/mailman I am using postfix as the MTA

Pipermail is installed

master.cf has this /usr/lib/mailman/bin/postfix-to-mailman.py

Notes in mailman docs

Integrating Postfix with Mailman

Create a list

http://hupi.org/mailman/create

Move a list from a different server

Spam control

Postgrey

I am using postgrey (installed from Ubuntu package).

Home page http://postgrey.schweikert.ch/

See http://www.howtoforge.com/greylisting_postfix_postgrey

Postgrey simply sends a message back on first connection refusing email and saying "come back later". It then creates a database (whitelist) entry and if the server connects to try again, lets it through.

NOQUEUE: reject: RCPT from oproxy2-pub.bluehost.com[67.222.39.60]: 450 4.2.0 <[email protected]>: Recipient address rejected: Greylisted, see http://postgrey.schweikert.ch/help/hupi.org.html; from=<[email protected]> to=<[email protected]> proto=SMTP helo=<oproxy2-pub.bluehost.com>


You can whitelist anyone manually by editing these files.

/etc/postgrey/whitelist_clients
/etc/postgrey/whitelist_recipients

Local (internal) mail is unaffected.

Databases are in /var/lib/postgrey/

Dump current whitelist database

perl /usr/share/doc/postgrey/postgrey_clients_dump

See also

man postgreyreport

More anti-spam

http://www.fatofthelan.com/technical/how-to-install-postfix-dovecot-amavis-clamav-and-spamassassin-etch/

Script to mass remove bouncing users

Puts a list of commands in /tmp/list that you then run as a script on the mailman server.

#!/usr/bin/env python
#
# 1 Read Brian's mailbox
# 2 Build a list of addresses to unsubscribe
# 3 Delete the emails
#
import re
import imaplib
from email.parser import Parser

user = '[email protected]'
password = 'xxxxxxxxx'
host = 'imap.googlemail.com'
mailbox = 'Inbox'
port = 993

d_collection = {}
re_mailing_list = re.compile(r'^http://hupi.org/cgi-bin/mailman/options/([^/]+)/(.*)%40(.*)\r')

def process_message(text):
    for line in text.split('\n'):
        mo = re_mailing_list.search(line)
        if mo:
            user = mo.group(2) + '@' + mo.group(3)
            if user in d_collection:
                d_collection[user] += 1
            else:
                d_collection[user] = 1
    return

def read_and_process_mail():
  
    mbox = imaplib.IMAP4_SSL(host,port)
    rc, resp = mbox.login(user, password)
    print rc, resp
    mbox.select(mailbox)
    typ, data = mbox.search(None, 'TO', '[email protected]')
    i = 0
    for num in data[0].split():
        typ, data = mbox.fetch(num, '(BODY[TEXT])')
        process_message(data[0][1])
        print "%d" % i
        i += 1
        mbox.store(num,'+FLAGS', '\\Deleted')
    mbox.expunge()
    mbox.close()
    mbox.logout()

read_and_process_mail()
fp = open('/tmp/list', 'w')
for k in d_collection:
    fp.write(k + "\n")
    print k
fp.close()