OfflineIMAP/offlineimap3

Converting between folder separators / invalid mailbox names

sndrsmnk opened this issue · 4 comments

Hi,

The mailing list seems dead, so i'm trying here...

I'm tasked with migrating IMAP mailboxes from an old provider to a new provider. The old provider uses / as folder separator, the new provider uses ..

Some mailboxes at the old provider have . in the name, eg: Archive/Dr. Jones. This seems to create Jones as a subfolder of Dr on the new provider: Archive.Dr.Jones.

Other mailboxes have names with multiple .'s in them (e.g. Some Stuff...) on the old provider, and they fail to sync because '...' has empty hierarchy separators causing 'Invalid mailbox name' IMAP error.

These mailboxes/folders fail to properly synchronise, in that no messages are copied, not even to the "wrong" subfolder Jones while there's 47 messages on the old provider's IMAP. The folder with multiple dots just breaks OfflineIMAP because of the IMAP-server error.

I tried fiddling with nametrans, putting both in the Local and Remote repository:

nametrans = lambda foldername: re.sub('\.', '_', foldername)

Even tried hacking around in the OfflineIMAP source a bit, but to no avail.

Am i missing an option here?

General informations

  • system/distribution (with version): Ubuntu 22.04
  • offlineimap version (offlineimap -V): offlineimap v8.0.0, imaplib2 v3.05, Python v3.10.6, OpenSSL 3.0.2 15 Mar 2022
  • Python version: v3.10.6
  • server name or domain: not relevant
  • CLI options: -o

Configuration file offlineimaprc

[general]
metadata = somemetadatapath
accounts = MyMigrationConfig
maxsyncaccounts = 1
ui = basic
socktimeout = 60
fsync = false

[Account MyMigrationConfig]
localrepository = Local
remoterepository = Remote
quick = 0

[Repository Local]
type = IMAP
remotehost = someip
remoteport = 143
ssl = no
starttls = no
remoteuser = someuser
remotepassfile = somepath/.imap_password
usecompression = no
maxconnections = 4
singlethreadperfolder = yes
expunge = no
subscribedonly = no
createfolders = True
sync_deletes = no
readonly = False

[Repository Remote]
type = IMAP
remotehost = someip
remoteport = 993
cert_fingerprint = somefingerprint
ssl = yes
tls_level = tls_compat
starttls = no
remoteuser = someuser
remotepassfile = /somepath/.imap_password
usecompression = no
maxconnections = 4
singlethreadperfolder = yes
expunge = no
subscribedonly = no
createfolders = True
sync_deletes = no
readonly = True
folderfilter = lambda foldername: not re.search('(?i)(Trash|Deleted|Verwijderd|Ongewenst|Junk)', foldername)

pythonfile (if any)

N/a.

Logs, error

2023-03-03 16:33:55 INFO: Creating folder Archief.Dr.Jones[Local]
2023-03-03 16:33:55 INFO: Creating new Local Status db for Local:Archief.Dr.Jones

No further errors are logged, no mails are synced.

Steps to reproduce the error

@sndrsmnk
Here's some good working examples, please have a look, and compare with yours:
https://www.offlineimap.org/doc/use_cases.html

Hi @sndrsmnk

with the information provided by @chris001 , is the problem solved? Could we close this issue?

Best regards,
kix

No the issue was not solved. But i worked around it in a different way and now i can no longer contribute to this ticket. So sure, i'll close it. Someone who might experience the same can re-open it or refer to this ticket if they find it!

Oh, just informationa for the search results: the remote end in my case was Cryus IMAP server. The local end was Dovecot IMAP server.