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