Finally I have found out what is causing the problem, it is a known issue with manage sieve: http://dovecot.org/pipermail/dovecot/2012-September/085585.html Unfortunately the Ubuntu repository has the buggy version, I just filed a bug report to upgrade it. Hopefully they will do that, otherwise I might have to install dovecot from source.