Renaming mailboxes

David Moyes info-cyrus at jelmail.com
Wed May 27 10:48:08 EDT 2020


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?

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.




More information about the Info-cyrus mailing list