imapsync icon indicating copy to clipboard operation
imapsync copied to clipboard

Issue with \Noselect

Open cmlavila opened this issue 7 years ago • 13 comments

Hi! There's a folder in a test mailbox that has \Noselect flag. This causes imapsync to fail the migration:

++++ Listing 3 errors encountered during the sync ( avoid this listing with --noerrorsdump ). Err 1/3: Host1 Folder 123456: Could not select: 30 NO Mailbox does not exist Err 2/3: Host1 folder 123456: Could not select: 69 NO Mailbox does not exist Err 3/3: Host1 Folder 123456: Could not select: 137 NO Mailbox does not exist Exiting with return value 111 Listing the folders, this is what we have:

`* LIST (\HasChildren \Noselect) "." "123456"

  • LIST (\HasNoChildren) "." "123456.54321"
  • LIST (\HasNoChildren) "." "123456.78910"`

How to handle those folders and have a successful migration? Thanks!

cmlavila avatar Sep 20 '18 18:09 cmlavila

Hi! Well, the strange thing here is that by default, imapsync does a tour on all requested folders, all folders by default, and check whether they can be selected or not. If a folder can't be selected, it has the \Noselect flag set, then imapsync removed it from the list of folders to be synced.

So several possibilities:

  1. A bug from an Perl module Mail::IMAPClient prior to 3.36. It used to be wrong about the function $imap->selectable( folder ) used by imapsync to detect selectability https://metacpan.org/changes/distribution/Mail-IMAPClient
version 3.36: Fri Aug 14 01:40:50 UTC 2015
        - rt.cpan.org#91912: selectable broke in 3.29 due to \b around \NoSelect
          [Justin Vallon, Gilles Lamiral]
  1. You use option --nocheckselectable and imapsync fails on it. I would say the error is then attended.

Solution to handle this "Could not select" error: avoid this folder with

 imapsync ... --exclude 123456

Or, if you still want the children folders,

  • on Windows:

    imapsync ... --exclude "^123456$"
    
  • on Unix/Linux/Mac:

    imapsync ... --exclude '^123456$'
    

gilleslamiral avatar Oct 03 '18 11:10 gilleslamiral

No news. Closing.

gilleslamiral avatar Jul 30 '19 11:07 gilleslamiral

Hi, I'm experiencying the same problem:

Err 1/50: Host1 folder "path/of/folder": Could not select: 1040 NO ""path/of/folder"" doesn't exist.
imapsync 1.882 on ubuntu 16.04.6 LTS.

Sync is done from MS Exchange to Zimbra. Mail::IMAPClient (3.42).

No option --nocheckselectable used.

sirio81 avatar Sep 27 '19 13:09 sirio81

What are those double-double quotes?

NO ""path/of/folder""

gilleslamiral avatar Sep 27 '19 14:09 gilleslamiral

I changed the path but the "" are as reported in the error. BTW, it seems like to error is caused by a backslash \ character in a folder name.

Running imapsync with --exclude '\\' seems to work with no errors. I wonder if it will give the same error when encountering one of these characters: ~ ! @ # $ % ^ & * ( ) _ + = { } | [ ] \ : ” ; ‘ < > , . ? / I see some folder's name with parenthesis ().

I'll report back if I'll get the same error with other folders.

sirio81 avatar Sep 27 '19 15:09 sirio81

Hi! Mail::IMAPClient 3.42 is ok but imapsync 1.882 is quite old to be the one I fine to debug, I prefer debug late releases. The two characters \ and ( are special in Perl and IMAP so well, we might be on a bug here. Next time, make a run with --debugimap

gilleslamiral avatar Sep 30 '19 08:09 gilleslamiral

No news. Closing again.

gilleslamiral avatar Feb 11 '20 22:02 gilleslamiral

I had this issue too, and wanted to share the solution here.

I got this error message:

Listing 18 errors encountered during the sync ( avoid this listing with --noerrorsdump ).
Err 1/18: Host1 Folder INBOX: Could not select: 16 NO [SERVERBUG] Internal error occurred. Refer to server log for more information. [2024-03-05 00:07:29] (0.000 + 0.000 secs).
Err 2/18: Host1 Folder INBOX.Archive: Could not select: 17 NO Mailbox doesn't exist: INBOX.Archive (0.000 + 0.000 secs).
Err 3/18: Host1 Folder INBOX.Drafts: Could not select: 18 NO Mailbox doesn't exist: INBOX.Drafts (0.000 + 0.000 secs).
Err 4/18: Host1 Folder INBOX.Junk: Could not select: 19 NO Mailbox doesn't exist: INBOX.Junk (0.000 + 0.000 secs).
Err 5/18: Host1 Folder INBOX.Sent: Could not select: 20 NO Mailbox doesn't exist: INBOX.Sent (0.000 + 0.000 secs).
Err 6/18: Host1 Folder INBOX.Trash: Could not select: 21 NO Mailbox doesn't exist: INBOX.Trash (0.000 + 0.000 secs).
Err 7/18: Host1 folder INBOX: Could not select: 22 NO Mailbox doesn't exist: INBOX (0.000 + 0.000 secs).
Err 8/18: Host1 folder INBOX.Archive: Could not select: 23 NO Mailbox doesn't exist: INBOX.Archive (0.000 + 0.000 secs).
Err 9/18: Host1 folder INBOX.Drafts: Could not select: 24 NO Mailbox doesn't exist: INBOX.Drafts (0.000 + 0.000 secs).
Err 10/18: Host1 folder INBOX.Junk: Could not select: 25 NO Mailbox doesn't exist: INBOX.Junk (0.000 + 0.000 secs).
Err 11/18: Host1 folder INBOX.Sent: Could not select: 26 NO Mailbox doesn't exist: INBOX.Sent (0.000 + 0.000 secs).
Err 12/18: Host1 folder INBOX.Trash: Could not select: 27 NO Mailbox doesn't exist: INBOX.Trash (0.000 + 0.000 secs).
Err 13/18: Host1 Folder INBOX: Could not select: 28 NO Mailbox doesn't exist: INBOX (0.000 + 0.000 secs).
Err 14/18: Host1 Folder INBOX.Archive: Could not select: 29 NO Mailbox doesn't exist: INBOX.Archive (0.000 + 0.000 secs).
Err 15/18: Host1 Folder INBOX.Drafts: Could not select: 30 NO Mailbox doesn't exist: INBOX.Drafts (0.000 + 0.000 secs).
Err 16/18: Host1 Folder INBOX.Junk: Could not select: 31 NO Mailbox doesn't exist: INBOX.Junk (0.000 + 0.000 secs).
Err 17/18: Host1 Folder INBOX.Sent: Could not select: 32 NO Mailbox doesn't exist: INBOX.Sent (0.000 + 0.000 secs).
Err 18/18: Host1 Folder INBOX.Trash: Could not select: 33 NO Mailbox doesn't exist: INBOX.Trash (0.000 + 0.000 secs).

And this is the imapsync command I used:

imapsync \
  --host1 host1.email.au --port1 143 --tls1 \
  --user1 "[email protected]" \
  --password1 password1 \
  --host2 host2.email.au --port2 143 --tls2 \
  --user2 "[email protected]" \
  --authuser2 admin --password2 password2 \
  --automap \
  --delete2duplicates \
  --debug \
  --dry

This happened because I use a master user to transfer the mailboxes, and the master user does not have access to the user's mailboxes. The solution is to modify the dovecot config and add these 2 lines:

plugin {
    # lines of the existing plugin block
    ... 

    acl_user=%u
    master_user=%u
}

Save the changes, and validate the config with this command:

doveconf >/dev/null && echo OK

If it returns no error or warning messages, restart the dovecot service. You should be able to proceed after that.

For more information check this out: https://doc.dovecot.org/configuration_manual/authentication/master_users/#acls

Hope this helps.

budiantoip avatar Mar 07 '24 02:03 budiantoip

@budiantoip had the same problem with dovecot (master user) and your fix helped! thanks ;)

discostur avatar Dec 19 '24 14:12 discostur

@budiantoip had the same problem with dovecot (master user) and your fix helped! thanks ;)

What fix?

gilleslamiral avatar Dec 19 '24 18:12 gilleslamiral

i had to adjust my dovecot config:

plugin {
    # lines of the existing plugin block
    ... 

    acl_user=%u
    master_user=%u
}

Then login via super master / admin user was possible for imapsync ;)

discostur avatar Dec 27 '24 15:12 discostur

At 2025 this save me, thanks, the problem was masteruser has no access permission to INBOX

enriluis avatar May 19 '25 20:05 enriluis

Okay, I leave this issue Open for eternity :-)

gilleslamiral avatar May 19 '25 20:05 gilleslamiral