diff options
author | Rob Funk <rfunk@funknet.net> | 2004-08-24 18:04:32 +0000 |
---|---|---|
committer | Rob Funk <rfunk@funknet.net> | 2004-08-24 18:04:32 +0000 |
commit | fd2543489b53fe34a18b7204d6803bf527c0d198 (patch) | |
tree | 13f1b84304d2dcc81df3a02abd9e368843418d4c /contrib | |
parent | 5cf6d4dfd6319a4798765004b32c0da775488f0e (diff) | |
download | fetchmail-fd2543489b53fe34a18b7204d6803bf527c0d198.tar.gz fetchmail-fd2543489b53fe34a18b7204d6803bf527c0d198.tar.bz2 fetchmail-fd2543489b53fe34a18b7204d6803bf527c0d198.zip |
Update mold_remover to version 0.3, from http://sf.net/projects/moldremover
svn path=/trunk/; revision=3933
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/README.mold_remover | 31 | ||||
-rw-r--r-- | contrib/mold_remover.py | 28 |
2 files changed, 54 insertions, 5 deletions
diff --git a/contrib/README.mold_remover b/contrib/README.mold_remover new file mode 100644 index 00000000..0f814885 --- /dev/null +++ b/contrib/README.mold_remover @@ -0,0 +1,31 @@ +Mold Remover + +Mold Remover is a short python script which integrates with fetchmail +<http://catb.org/~esr/fetchmail/> and allows the user to specify the +number of days that mail should remain on the pop3 server before being +deleted. + +It is released under the GNU GPL <http://www.gnu.org/copyleft/gpl.html>. + +Usage: +Set up fetchmail to run with keep and uidl options. +Edit the mold_remover.py file to specify the mailserver address +and login/password details. Also specify the UIDL file created by +fetchmail (this is created automatically by fetchmail when uidl option +is selected in the fetchmailrc file usually at +/var/mail/.fetchmail-UIDL-cache). Remember to chmod the moldremover +script to 700 so that passwords cannot be read. Next, edit the field to +set how many days you want the mail to be left on the server. Lastly +create a script to run moldremover.py with python which can either be +run as a cron job or as part of your connection script. It is advisable +to stop fetchmail before mold remover is run and then to restart +fetchmail afterwards. Here is an example /etc/cron.daily/ script: + +#!/bin/bash +/etc/init.d/fetchmail stop >> /var/log/messages +/usr/bin/python /usr/local/bin/mold_remover.py >> /var/log/messages +/etc/init.d/fetchmail start >> /var/log/messages + +Please feel free to email me (jmstone@dsl.pipex.com) if you have any questions or bugfixes! + +James Stone diff --git a/contrib/mold_remover.py b/contrib/mold_remover.py index 1ccba7c3..4c5ca222 100644 --- a/contrib/mold_remover.py +++ b/contrib/mold_remover.py @@ -1,8 +1,24 @@ # Mold Remover +# # A short python script to remove old read mail from a pop3 mailserver. +# Distributed under the GNU GPL (http://www.gnu.org/copyleft/gpl.html) # Dovetails with fetchmail with keep option. -# Run it as a cron job... -# Version 0.1 by James Stone (stone1@btinternet.com) +# Run it as a cron job... Remember to stop fetchmail in the cron job +# before calling mold_remover, and to restart fetchmail after mold_remover +# e.g.: +# +# /etc/init.d/fetchmail stop >> /var/log/messages +# /usr/bin/python /usr/local/bin/mold_remover.py >> /var/log/messages +# /etc/init.d/fetchmail start >> /var/log/messages +# +# Version 0.3 by James Stone (jmstone@dsl.pipex.com) +# 15th March 2004 +# +# Changes: +# 0.1 25th September 2003 Original version +# 0.2 6th March 2004 Info added regarding use, and explicit mention of GPL made. +# 0.3 15th March 2004 days changed to list, 1 day changed from 24 to 23 hours. +# # please submit bug reports and code optimisations as you see fit! import string @@ -10,12 +26,14 @@ import poplib import time #user editable section + mailserver=["mail.server1","mail.server2"] #list of mailservers login=["login1","login2"] #list of logins for corresponding mailserver password=["pass1","pass2"] #list of passwords (note: chmod 700 for this script) -days=2 #number of days to keep on server. +days=[2,3] #number of days to keep on server. localuidlcache="/var/mail/.fetchmail-UIDL-cache" #fetchmail's UIDL cache localuidldate="/var/mail/.UIDLDate" #mold remover's UIDL datefile + #end of user editable section readfile=open(localuidlcache, 'r') @@ -41,7 +59,7 @@ for a in range(len(mailserver)): for uidldate in datefile: uidldatesplit=uidldate.split(' ') if(connectedto==int(uidldatesplit[2])): - if (time.time()-float(uidldatesplit[1]))>(86400*days): + if (time.time()-float(uidldatesplit[1]))>(86400*days[a]-3600): try: recheckuidl=connect.uidl(mesnum+1) recheckuidlsplit=recheckuidl.split(' ') @@ -63,7 +81,7 @@ for a in range(len(mailserver)): datefile.seek(0) for uidldate in datefile: uidldatesplit=uidldate.split(' ') - if not(time.time()-float(uidldatesplit[1]))>(86400*days): + if not(time.time()-float(uidldatesplit[1]))>(86400*days[int(uidldatesplit[2])]): tempfile.write(uidldate) datefile.close() datefile=open(localuidldate,'w+') |