Comments on Automatic Cleaning Of Trash And/Or Junk Folders With ISPConfig (With Roundcube + Tmpreaper (Tmpwatch))
Automatic Cleaning Of Trash And/Or Junk Folders With ISPConfig (With Roundcube + Tmpreaper (Tmpwatch)) This short mini-howto will help you set up automatic cleaning of Trash- and Junkfolders. Most (web)mail clients (can) automatically create these. A lot of people don't clean there maildirectories causing Junk and Trash folders to grow massively in size and with ISPConfig (not yet) being able to set good maildirectory size limits the alternative is to have these folders cleaned after several days.
5 Comment(s)
Comments
This script is very cool! Bye bye my old spam!
Changed for ispconfig 3.0 on Debian Lenny
#!/bin/sh
# Time to wait before removing mails from the Junk folder (Default: 7 days) Set 0 to turn off.
junk_max_hours=$((24*7))
# Time to wait before removing mails from the Trash folder (Default: 30 days) Set 0 to turn off.
trash_max_hours=$((24*30))
for domain in /var/vmail/*
do
if [ -d "$domain" ]
then
for user in $domain/*
do
if [ "$junk_max_hours" -gt "0" ]
then
if [ -d "$user/.Junk" ]
then
tmpreaper -m $junk_max_hours $user/.Junk/{cur,new}
fi
fi
if [ "$trash_max_hours" -gt "0" ]
then
if [ -d "$user/.Trash" ]
then
tmpreaper -m $trash_max_hours $user/.Trash/{cur,new}
fi
fi
done
fi
done
I think there still is missing at the end of this command:
chmod +x /etc/cron.daily/clean-mailfolders
Changed to use doveadm
#!/bin/sh# Time to wait before removing mails from the Junk folder (Default: 7 days) Set 0 to turn off.#junk_max_hours=$((24*7))junk_max_days=30# Time to wait before removing mails from the Trash folder (Default: 30 days) Set 0 to turn off.#trash_max_hours=$((24*30))trash_max_days=0for dir in $(ls -d /var/vmail/*); do # extracting only basename domain=${dir##*/} for mbox in $dir/*; do user=${mbox##*/} if [ "$junk_max_days" -gt "0" ]; then if [ -d "$mbox/Maildir/.Junk" ]; then /usr/bin/doveadm expunge -u $user@$domain mailbox Junk savedbefore ${junk_max_days}d fi fi if [ "$trash_max_days" -gt "0" ]; then if [ -d "$mbox/Maildir/.Trash" ]; then /usr/bin/doveadm expunge -u $user@$domain mailbox Trash savedbefore ${trash_max_days}d fi fi donedone
dovecotadm cleaned up a bit. :)
#!/bin/sh# Time to wait before removing mails from the Junk folder junk_max_days=30# Time to wait before removing mails from the Trash foldertrash_max_days=30for dir in $(ls -d /var/vmail/*);do # extracting only basenamedomain=${dir##*/} for mbox in $dir/*; do user=${mbox##*/} if [ "$junk_max_days" -gt "0" ]; then if [ -d "$mbox/Maildir/.Junk" ]; then /usr/bin/doveadm expunge -u $user@$domain mailbox Junk savedbefore ${junk_max_days}d fi fi if [ "$trash_max_days" -gt "0" ]; then if [ -d "$mbox/Maildir/.Trash" ]; then /usr/bin/doveadm expunge -u $user@$domain mailbox Trash savedbefore ${trash_max_days}d fi fi donedone