Doveadm-Expunge bash script

This script will call Doveadm-Expunge based on users in home directory.

#!/bin/bash
FOLDERS=/home/*
for f in $FOLDERS
do
doveadm expunge -u "$(basename $f)" mailbox Spam savedbefore 14d;
doveadm expunge -u "$(basename $f)" mailbox Trash savedbefore 7d;
done

2 thoughts on “Doveadm-Expunge bash script

  1. Hi,

    1) What would happen if user has a spacebar in his username? (“for” won’t work) You are missing -> “$var”

    2) What about other folders where messages have been flagged as deleted but have not been moved to Trash or Spam folders?

Leave a Reply

Your email address will not be published. Required fields are marked *