Delete trash from Courier IMAP Maildir
Outlook doesn't move deleted mails to the IMAP server's Trash folder, and apparently cannot be told to do so. It doesn't move them to it's own local trash folder either. Depending on configuration, it either:
This means the Maildir on the server is filled up with mails marked for deletion, which users cannot (easily) delete since they don't even see them.
Convincing the users that Outlook is a bad email client is hopeless, so we need another way to get rid of these old files.
Fortunately, on my Courier IMAP server, files marked for deletion are easily recognized by the "T" at the end of the file name. (See "Reading mail from maildirs" in the Courier documentation).
So what I do is delete files which have been marked for deletion for some time (30 days in the example below). When it is marked, the file's ctime changes.
Adapt to your needs:
- deletes them straight away
- shows them greyed out and overlined
- marks them as deleted, and hides them
This means the Maildir on the server is filled up with mails marked for deletion, which users cannot (easily) delete since they don't even see them.
Convincing the users that Outlook is a bad email client is hopeless, so we need another way to get rid of these old files.
Fortunately, on my Courier IMAP server, files marked for deletion are easily recognized by the "T" at the end of the file name. (See "Reading mail from maildirs" in the Courier documentation).
So what I do is delete files which have been marked for deletion for some time (30 days in the example below). When it is marked, the file's ctime changes.
Adapt to your needs:
find /home/*/Maildir/ -ctime +30 -type f -name "*T" -exec rm -f "{}" \;
2 Comments:
rming deleted files tends to cause problems with certain kinds of users. Unfortunately, those users are the kind that write the checks. So I'm intending to write a utility that will move messages marked with a T into a .Trash folder and remove the T. I'll let you know how it goes.
Not sure if you ever got it done but here's my dirty script to move to trash file:
#!/bin/bash
INTERVAL=1
while true
do
find /home/e-smith/files/users/*/Maildir/ -type f -name "*T*" -exec echo {} >> /tmp/deleted.imap \;
exec 3<&0
exec 0</tmp/deleted.imap
i=0
while read line
do
filepath=${line%/Maildir/*}
filename=${line##*/}; newfilename=${filename//T/}
moveto="$filepath/Maildir/.Trash/cur/$newfilename"
mv "$line" "$moveto"
i=$(($i+1))
done
exec 0<&3
if [ $i -gt 0 ]
then
echo "$i messages moved from $filepath"
fi
rm -f /tmp/deleted.imap
sleep $INTERVAL
done
I run it in a screen so I can reconnect and check they're still moving...
Post a Comment
<< Home