Renaming mailboxes
Marco
falon at ruparpiemonte.it
Fri Jun 5 05:53:00 EDT 2020
Hello David,
Il 27/05/2020 16:48, David Moyes ha scritto:
>
> I want to rename a mailbox (and all of its descendants), however I am
> struggling with what, on the surface, would appear to be a simple task.
>
> I first tried to use cyradm rename command to rename user.foo to
> user.foo at example.com, like this:
>
> localhost> rename user.foo user.foo at example.com
>
> However the rename command does not appear to be recursive, and I could
> not find any argument to tell it to recurse. Do I have this right or am
> I doing something wrong?
from what I remember, the rename is "recursive". If you login as an
admin you can simply rename all users mailboxes from a name to a new
name in a single step.
If you login as the user, then you have to move all folders as you
describe below. Pay attention to specialuse folders and to the xapian
indexes which could increase a lot.
I didn't remember on cyradm, but I currently use Cyrus::IMAP::Admin for
almost all my scripts. I don't know if something of this could be useful
for you:
https://github.com/falon/cyr_scripts
https://cloudsmith.io/~csi/repos/cyrus-scripts/packages/
(see at cyr_moveMailboxPart.pl, cyr_moveINBOX.pl)
Greetings
Marco
> I decided to try it in a Perl script using Cyrus::IMAP::Admin. By doing
> a `list` I could get the mailbox and its descendants like this:
>
> @mailboxes = $client->list("user/$oldname");
> @mailboxes_sub = $client->list("user/$oldname/*");
> push (@mailboxes , @mailboxes_sub);
>
> (I found that listing "user/$oldname*" got me user.foo but also
> user.foobar so I had to combine two calls to prevent that.)
>
> Then I could iterate over the mailboxes doing
>
> $client->rename( $oldmailbox, $mailbox );
>
> However, nothing works after the first rename; the program just exits,
> not even "or die" error messages are displayed. In case it means
> anything, the exit status is 141 which I think indicates a SIGPIPE (as
> confirmed using `kill -l "$?"` which returns `PIPE`).
>
> I did also notice a similar thing in cyradm, that after doing a rename
> that subsequent action caused cyradm to exit:
>
> localhost> rename user/testuser/Trash user/test at example.net/Trash
> renamemailbox:
> localhost> lm # this curiously returns nothing!
>
> localhost> echo $?
> 0
> localhost> lm
> [cyrus at fee7fffd9be7 ~]$ echo $?
> 141
>
>
> Any help would be greatly appreciated. I am currently using cyrus-imapd
> 3.0.13-3 on Arch Linux.
>
>
> ----
> Cyrus Home Page: http://www.cyrusimap.org/
> List Archives/Info: http://lists.andrew.cmu.edu/pipermail/info-cyrus/
> To Unsubscribe:
> https://lists.andrew.cmu.edu/mailman/listinfo/info-cyrus
>
More information about the Info-cyrus
mailing list