How to purge the Maildir inbox for all system accounts: /home/user/Maildir

#!/bin/sh

#Deletes emails older than this number of days
OLD_THAN_DAYS=30

for i in `ls /usr/local/directadmin/data/users`; do
{
if [ ! -d /home/$i/Maildir ]; then
continue;
fi

for file in `find /home/$i/Maildir -mtime +${OLD_THAN_DAYS} | grep -E ‘/cur/|/new/’`; do
{
rm -fv $file;
};
done;
};
done;
exit 0;

Was this article helpful?

Related Articles