[Dovecot] Automatic expire on post-login

Timo Sirainen tss at iki.fi
Wed Nov 24 19:22:12 EET 2010

On 24.11.2010, at 9.47, Antonio Perez-Aranda wrote:

> This is the content of postlogin.sh
> #!/bin/bash
> /usr/local/bin/doveadm -D expunge -A mailbox Trash savedbefore 30d
> /usr/local/bin/doveadm -D expunge -A mailbox MarcaSpam savedbefore 1w
> exec $*

-A means it goes through all users, which most likely isn't what you want. Rather use -u $USER. Also add some check that this expunging isn't done more than once a day. Something like:

if [ ! -f expungestamp ] || [ `find Makefile -mtime +1d` != "" ]; then
  touch expungestamp
  doveadm ..

Alternatively if this is too slow you could also build a plugin to do this (mostly copy&paste code from doveadm-mail-expunge.c).

More information about the dovecot mailing list