[Dovecot] Maildirmake equiv?
Thomas Leuxner
tlx at leuxner.net
Fri Aug 16 21:47:30 EEST 2013
* LuKreme <kremels at kreme.com> 2013.08.16 20:15:
> MDM is only invoked if the target folder doesn't exist. For example, for this list the current target folder is .zz.dovecot.2013. Next year, it will change to .zz.dovecot.2014
>
> (the .zz is because iOS mail does't support unsubscribing from mailboxes and doesn't let you collapse folders, so the zz puts these archive folders way at the end.)
Here's a script I wrote to archive old mail using doveadm. It should be simple enough to tweak it to your needs. Basically you call it with a mailbox name and it will archive all mails before a certain date. Source and Destination Path are in the script code:
dovearchive.sh:
#!/bin/bash
# Archive old posts before certain date to 'Public/Archive/Mailbox/Year'
# Set basic parameters accordingly:
# archive=2011, before_date=$year-mm-dd
# source_mailbox_base=Public/Newsletters
# dest_mailbox_base=Public/Archive/Newsletters
# Actual Mailbox is read from command line
set -e
archive=2012
let year=$archive+1
before_date=$year-01-01
mailbox_owner=tlx at leuxner.net
source_mailbox_base='Public/Newsletters'
dest_mailbox_base='Public/Archive/Newsletters'
#acl_admin_group=owner
acl_admin_group='group=PublicMailboxAdmins'
acl_unlock_seq="$acl_admin_group delete expunge insert lookup post read write write-seen write-deleted"
acl_lock_seq="$acl_admin_group insert lookup post read write write-seen"
acl_lock_archive="$acl_admin_group insert lookup read write write-seen"
msg_formatted() {
echo "$(date "+%b %d %H:%M:%S") $*"
}
if [ $# -eq 0 ]; then
echo "usage: $0 mailbox" >&2
exit 1
fi
# Mailbox exists?
doveadm acl get -u $mailbox_owner "$source_mailbox_base/$1" || { echo 'Mailbox not found.'; exit 1; }
# Create New Archive Mailbox
doveadm mailbox create -u $mailbox_owner "$dest_mailbox_base/$1/$archive"
# Modify ACL, expunge mail and revert ACL
msg_formatted "[>] Archiving \"$dest_mailbox_base/$1/$archive\""
doveadm acl set -u $mailbox_owner "$source_mailbox_base/$1" $acl_unlock_seq
doveadm move -u $mailbox_owner "$dest_mailbox_base/$1/$archive" mailbox "$source_mailbox_base/$1" before $before_date
doveadm acl set -u $mailbox_owner "$source_mailbox_base/$1" $acl_lock_seq
doveadm acl set -u $mailbox_owner "$dest_mailbox_base/$1/$archive" $acl_lock_archive
msg_formatted '[ Complete ]'
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://dovecot.org/pipermail/dovecot/attachments/20130816/145edbb8/attachment.bin>
More information about the dovecot
mailing list