Răzvan Sandu
2013-Aug-06 16:31 UTC
[Dovecot] Please HELP: how to delete all messages older than X days from the server?
Hello, Would you please help me solve the following case? My (CentOS) server runs dovecot and allows both POP3 and IMAP service. Users are virtual users (no home directories), with messages stored in Maildir directories under /var/spool/mail/vhosts/example.com/username Some of them use mobile devices (without local storage space), so I must allow IMAP access, not just POP3. But the storage on the server must be for a strictly *limited* period of time. As an admin, I'm trying to force each user to: - download *locally* received messages when they arrive at the office - don't let copies of messages on the server (incoming, sent, trash, drafts, etc.) For various reasons, e-mail client configuration is not under my control (I can't rely on client configuration for implementing this). Implementing filesystem quotas is not an option because a. presently, all virtual users share same UID/GID on the server and b. administrative reasons (the "full quota" situation may occur unexpectedly and this is not tolerable in corporate policy). So I need EITHER: 1. a method of downloading locally *all* messages from the server (incoming, sent, trash, drafts, etc.) to the workstation, when the user consults his/her mailbox from a POP3 desktop client, thus completely *emptying* the user's mailbox on the server OR 2. an automatic, elegant but forceful method of deleting all messages older than X days (incoming, sent, trash, drafts, etc.) I've tried to use a line such as: doveadm expunge -u john.doe at example.com before 4w run as root, from a script in crontab, but for "expunge" doveadm won't let me skip the "-u" parameter (to perform the expunge for *all* users). Could you please help? Any sugestion is welcomed. Thanks a lot, R?zvan -------------- next part -------------- A non-text attachment was scrubbed... Name: razvan_sandu.vcf Type: text/x-vcard Size: 424 bytes Desc: not available URL: <http://dovecot.org/pipermail/dovecot/attachments/20130806/6494f363/attachment.vcf>
Pascal Volk
2013-Aug-06 17:18 UTC
[Dovecot] Please HELP: how to delete all messages older than X days from the server?
On 08/06/2013 06:31 PM R?zvan Sandu wrote:> ? > Implementing filesystem quotas is not an option because a. presently, > all virtual users share same UID/GID on the server and b. administrative > reasons (the "full quota" situation may occur unexpectedly and this is > not tolerable in corporate policy).Use Dovecot's quota plugin - which supports different backends. Each user may have a different quota limit. * http://wiki2.dovecot.org/Quota> So I need EITHER: > > 1. a method of downloading locally *all* messages from the server > (incoming, sent, trash, drafts, etc.) to the workstation, when the user > consults his/her mailbox from a POP3 desktop client, thus completely > *emptying* the user's mailbox on the serverUsually only the INBOX is visible via POP3 ?> OR > > 2. an automatic, elegant but forceful method of deleting all messages > older than X days (incoming, sent, trash, drafts, etc.)There is the expire plugin for Dovecot. * http://wiki2.dovecot.org/Plugins/Expire> I've tried to use a line such as: > > doveadm expunge -u john.doe at example.com before 4w > > run as root, from a script in crontab, but for "expunge" doveadm won't > let me skip the "-u" parameter (to perform the expunge for *all* users). > > > Could you please help? Any sugestion is welcomed.There is also the -A option, see http://wiki2.dovecot.org/Tools/Doveadm/Expunge#section_options Regards, Pascal -- The trapper recommends today: cafebabe.1321819 at localdomain.org
Răzvan Sandu
2013-Aug-07 08:22 UTC
[Dovecot] Please HELP: how to delete all messages older than X days from the server?
On Tue, 06 Aug 2013 19:18:15 +0200, Pascal Volk a scris:> There is also the -A option, see > http://wiki2.dovecot.org/Tools/Doveadm/Expunge#section_optionsThank you, but doveadm expunge will ask for the mailbox name: [root at mail1 ~]# doveadm expunge -u john.doe at example.com ON 2013-08-07 doveadm(root): Fatal: expunge: To avoid accidents, search query must contain MAILBOX in all search branches What I need is to traverse *all* directories under /var/spool/mail/vhosts/domainname/ (which are /var/spool/mail/vhosts/domainname/username, with further variable subdirectories, name never known in advance...) and to delete all messages older than X days (incoming, sent, drafts, trash, etc.) This must be done without manual confirmation ("are you sure...?") (if I do it via a script run from cron).>From the examples given in the wiki page, the expire plugin presents thesame problem: one must know in advance the *name of the mailbox* he has to empty. Also for the correct search criteria: should I use SAVEDBEFORE or SENTBEFORE ? Thanks again, R?zvan -------------- next part -------------- A non-text attachment was scrubbed... Name: razvan_sandu.vcf Type: text/x-vcard Size: 452 bytes Desc: not available URL: <http://dovecot.org/pipermail/dovecot/attachments/20130807/6b92ba66/attachment.vcf>