(Mailfilter only checks headers, so can't see filenames of attachments.) I've got this in my crontab: */5 * * * * (/home/me/pop_zap_msft.py && fetchmail -s)
The rc (named ~/.pop_zap_msftrc) has this *exact* format: SERVER=pop.someisp.net USER=snarfle PASS=blah Hope you find it useful.... -- ----------------------------------------------------------------- Ron Johnson, Jr. [EMAIL PROTECTED] Jefferson, LA USA "Vanity, my favorite sin." Larry/John/Satan, "The Devil's Advocate"
#!/usr/bin/python import sys, os import getpass, poplib, string import re ################ def check_re(d, patt_re, patt, s): mo = patt_re.search(s) if mo: d[patt] = s return d ################ cfg = {'SERVER': '', 'USER': '', 'PASS': ''} n = os.getenv('HOME') + '/.pop_zap_msftrc' f = open(n, 'r') l = f.readlines() f.close() for e in l: g = e.split('=') cfg[g[0]] = g[1][:-1] print cfg['SERVER'] print cfg['USER'] M = poplib.POP3(cfg['SERVER']) M.user(cfg['USER']) M.pass_(cfg['PASS']) ###M.pass_(getpass.getpass()) from_pattern = re.compile("^from\:") subj_pattern = re.compile("^subject\:") date_pattern = re.compile("^date\:") msft1_pattern = re.compile("^content-disposition: attachment; filename=") msft2_pattern = re.compile("\.(exe|bat)$") w = M.list() print w[0] print w[1] print w[2] print '==============================================' size_array = w[1] numMessages = len(size_array) print 'Num emails ', numMessages for i in range(1, numMessages+1): d = {'from': '', 'subj': '', 'date': '', 'attach': '', 'msft': ''} x = M.top(i, 25) a = string.split(size_array[i-1], ' ') ndx = int(a[0]) bcnt = int(a[1]) for y in x[1]: y1 = y.lower() d = check_re(d, from_pattern, 'from', y1) d = check_re(d, subj_pattern, 'subj', y1) d = check_re(d, date_pattern, 'date', y1) d = check_re(d, msft1_pattern, 'attach', y1) print '%d %d' % (ndx, bcnt) if d['attach'] != '': d = check_re(d, msft2_pattern, 'msft', y1) if d['attach'] != '': print d['from'] print d['subj'] print d['date'] print d['attach'] print d['msft'] M.dele(i) print 'DELETED THIS EMAIL!!!!!!!!!' M.quit() print '============================================================' print '============================================================'