Mailwatchy kind of question but not really OT

Eduardo Casarero ecasarero at gmail.com
Wed Jun 23 18:09:38 IST 2010


2010/6/23 Alex Neuman <alex at rtpty.com>

> I've got a user who got his laptop stolen and used POP for his email. The
> default action for nonspam being "store", his emails can be "released" so he
> can receive them again.
> If I wanted to do a little script-fu to release everything "to or from
> him", what would I have to find/grep/formail to just send everything out in
> one swoop? Any ideas? Thanks in advance.
> --
>

In the past i wrote this "script" to release a lot (over 10000) emails from
quarantine because of a wrong blacklist entry. I havent run it in a while so
take it with extreme care. also you have to modify the "release order"
according to your mailwatch installation.

you have to customize the sql select to match your from/to/etc.

hope it helps you!

massive_releasery.py

#! /usr/bin/env python

# Masive Releaser
# Desc: Este script ejecuta un query SQL para obtener el set de ids para
hacer el release de cuarentena
# Writed by Eduardo Casarero eduardo.casarero at informaticaavanzada.com.ar -
Ene 2008
# v0.01 - Version Inicial

import datetime
import MySQLdb
import os
import time

MYSQL_IP='localhost'
MYSQL_USER='root'
MYSQL_PASS='myrootpassword'
SQL_LOW_LIMIT=0
SQL_HIGH_LIMIT=500
LOG_FILE='/tmp/masive_releaser.log'
counter= SQL_LOW_LIMIT

#Genero la conexion a la base de datos
dbcontroller=MySQLdb.connect(host=MYSQL_IP,user=MYSQL_USER,passwd=MYSQL_PASS,db='mailwatch')
cursorcontroller=dbcontroller.cursor()

#Contadores de tiempo para control
t0=time.time()
#Calculando la fecha
fecha = datetime.datetime.now()

sql='SELECT id,hostname FROM maillog WHERE date > "2009-04-31" and
from_domain="amadeus.net" and to_domain="domain.com" and isspam="1";'

#print sql
cursorcontroller.execute(sql)
id_mails=cursorcontroller.fetchall()
counter_time=0

for id_mail in id_mails:
    if (counter_time==15):
 time.sleep(60)
counter_time=0
    os.system('echo "Releasing this '+str(id_mail[0])+' nro:'+str(counter)+'
de '+str(SQL_HIGH_LIMIT)+'" >>'+LOG_FILE)
    release_order = 'php release_msg.php '+str(id_mail[1])+' 80
'+str(id_mail[0])+' >>'+LOG_FILE+' 2>>1'
    os.system(release_order)
    #print release_order
    counter=counter+1
    counter_time=counter_time+1
    print str(id_mail[0])+" Released nro:"+str(counter)+' de
'+str(SQL_HIGH_LIMIT)

#closing db connection
dbcontroller.close()

# END



>
> Alex Neuman
> BBM 20EA17C5
> +507 6781-9505
> Skype:alex at rtpty.com <Skype%3Aalex at rtpty.com>
> --
> MailScanner mailing list
> mailscanner at lists.mailscanner.info
> http://lists.mailscanner.info/mailman/listinfo/mailscanner
>
> Before posting, read http://wiki.mailscanner.info/posting
>
> Support MailScanner development - buy the book off the website!
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.mailscanner.info/pipermail/mailscanner/attachments/20100623/d9cd5a71/attachment.html


More information about the MailScanner mailing list