Pruning “Trash” and “Spam” folders automatically

The accountpruner is a powerful tool, but it’s not always the easiest gizmo to figure out. With that in mind, here are some rules from my \MDaemon\App\midnight.bat file that might be useful.

c:\MDaemon\App\AccountPrune.exe /m /d=28 /p=”Spam.IMAP”
c:\MDaemon\App\AccountPrune.exe /m /d=28 /p=”Junk Mail.IMAP”
c:\MDaemon\App\AccountPrune.exe /m /d=28 /p=”Junk E-mail.IMAP”
c:\MDaemon\App\AccountPrune.exe /m /d=2 /p=”Trash.IMAP”
c:\MDaemon\App\AccountPrune.exe /m /d=2 /p=”Deleted Items.IMAP”
c:\MDaemon\App\AccountPrune.exe /m /d=2 /p=”Deleted Messages.IMAP”

The result is that at midnight each night, MDaemon’s accountpruner will go through each user’s mailbox, and in each of the “Spam”, “Junk Mail” and “Junk E-Mail” folders, delete all messages over 28 days old.

In the “Trash”, “Deleted Items” and “Deleted Messages” folders, messages over 2 days old will be deleted.  Combine this with the accountpruner’s own options to delete IMAP mail flagged as deleted, and you’ll have a solution that works for users of all mail clients, whether the mail client uses a dedicated “Trash” folder, uses IMAP deleted flag, or both.

MDaemon’s use of batch files

I’ve recently become aware that not everyone knows what midnight.bat is, so I thought I’d discuss MDaemon’s batch files a little.

MDaemon can act upon a number of batch files in the \MDaemon\App\ directory.

learn.bat — MDaemon creates this one each time a spamlearn session is about to run. Do not edit this file, your changes will simply be overwritten. Feel free to run this batch file yourself or through a scheduler if you wanted to schedule learning manually.

mylearn.bat — Each time MDaemon is about to run learn.bat, MDaemon will first look for the existance of mylearn.bat. If mylearn.bat exists, it will be run instead of learn.bat. If you want to modify learn.bat’s behaviour, copy it to mylearn.bat and edit to your heart’s content, just be warned that if you change any options in MDaemon’s spam learning dialog, you need to update mylearn.bat manually.

cleanup.bat — This is similar to learn.bat, but is used by MDaemon to launch the accountpruner and listpruner. Like learn.bat, you shouldn’t edit this file, your changes will be eaten.

mycleanup.bat — This is similar to mylearn.bat, but applies to cleanup.bat’s functionality. All the same rules and caviets apply.

midnight.bat — This batch file is executed by MDaemon at midnight each night. The purpose is as a simple scheduler, to allow you to run your own mycleanup.bat type tasks, but without disabling cleanup.bat in the process.

startup.bat — This batch file is executed as part of MDaemon’s startup process. This allows you to do some scheduled/scripted cleanup when MDaemon starts. You can also start or stop other services here.

In all cases, if the batch file you want doesn’t exist, you can create it.