Script: Automatically Cleans Up Trash and Junk/Spam Maildir Directories

Interworx Maildir Clean Up

This PHP script does the following:

  1. Dynamically queues all current domains to build a domain list.
  2. Using the domain list checks for all current email accounts.
  3. Deletes any messages in the Trash or Spam/Junk new and cur directories that are x days old.

The Trash and Junk mail days are separately configured. This way you can say set a shorter delay for Trash messages and longer for Junk. You simply crontab this PHP script and then your server will automatically flush old messages. Far better than relying on a client.

I hope this helps your setup.

Current Version: 1.4 Released On 4 March 2014 - New feature: The ability to change the mail path which now defaults to /var instead of /chroot/home.
Upgrading: The cli sytnax as changed so please see the readme.

Note: If you are looking for custom PHP development feel free to contact me.

maildircleanup-1.4.zip (2.66 KB)

Excellent script! Thank you for sharing! I had to modify it, though, since the home folder isn’t chrooted on my new server for some reason.

Chris

[QUOTE=ChrisZ;25345]Excellent script! Thank you for sharing! I had to modify it, though, since the home folder isn’t chrooted on my new server for some reason.

Chris[/QUOTE]

Awesome! I’m glad you found it useful. It is interesting that your IW isn’t using /chroot. I wonder why the difference?

Since I am a new IW user I am not sure why this is the case as I would have guess they were all the same. I am still learning how IW organizes its environment. So is your environment using the same paths just without the leading /chroot? In otherwords /home/vpopmail?

This would be easy to check for in the script so you wouldn’t have to edit anything.

Hi Jeremy

I think you will find there are many variations of users systems for single and clustered, and that’s the reason for not always using using chroot.

It is upto the user who sets up the system os to decide, not IW install, and more information is shown on IW website, docs, install.

I hope that helps you a little

Many thanks

John

Well I could solve this easily. I could have the script load the starting path from the command line. That would be easy enough.

Anyone want this feature?

Hi Jeremy

I think asking the question may not give you a lot of answers sorry, but for a highly professional polished script, if it’s not too much work, I would just do it, as it’s reputation and personal contentment, which cannot be bought.

I could be wrong though, and I understand any feeling if you prefer not too, it would be lovely if all users shared their code.

Have a lovely night

Many thanks

John

Hi Jeremy!

No worries! It caught me completely off-guard, too, because I had written a number of scripts for some clients that were on a server I just retired (using chroot) and the scripts were “broken” after I migrated them to the current server. As John said, there was probably an option I set on the retired server and forgot to set on the new server.

Thanks again!
Chris

Hello community,

I have released a new version of this script which now allows for the easy modification of the vpopmail directory. It now defaults to /var instead of /chroot/home however this is easy to alter. I did change the cli syntax so please consult the readme file.

Use Wordpress? Have clients that use Wordpress? Know of people that use Wordpress? You might want to check out this Wordpress thread.

Also if you are looking for custom PHP development feel free to contact me.