User Tools

Site Tools


doc:appunti:linux:sa:offlineimap3_nametrans

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
doc:appunti:linux:sa:offlineimap3_nametrans [2024/03/22 11:02] niccolodoc:appunti:linux:sa:offlineimap3_nametrans [2024/03/22 11:19] – [Testing the nametrans option] niccolo
Line 1: Line 1:
 ====== offlineimap3 IMAP syncronization: nametrans ====== ====== offlineimap3 IMAP syncronization: nametrans ======
 +
 +In this page we study a case of IMAP syncronization from a source IMAP server to a Maildir structure on local disk, using the **[[https://github.com/OfflineIMAP/offlineimap3|offlineimap3]]** tool.
 +
 +The main issue is the need to **map the source directory tree** into a tree compatible with the receiving Maildir hierarchy. Here are the issues:
  
 The **source IMAP** server has the following characteristics: The **source IMAP** server has the following characteristics:
Line 13: Line 17:
   * The "." character is not allowed in folder names.   * The "." character is not allowed in folder names.
  
-In this case we need a very special **nametrans** expression.+In this case we need a very special **nametrans** expression into the [[https://github.com/OfflineIMAP/offlineimap3|offlineimap3 configuration file]].
  
 :!: **NOTICE**: The mapping of the top-level folders under the INBOX during the transfer from IMAP to Maildir prevents the reverse mapping from Maildir to IMAP, therefore only synchronization from IMAP to Maildir will be possible and not vice versa. :!: **NOTICE**: The mapping of the top-level folders under the INBOX during the transfer from IMAP to Maildir prevents the reverse mapping from Maildir to IMAP, therefore only synchronization from IMAP to Maildir will be possible and not vice versa.
 +
 +===== Testing the nametrans option =====
  
 It is possibile to write a simple Python script to test the **nametrans** expression: It is possibile to write a simple Python script to test the **nametrans** expression:
Line 61: Line 67:
 "INBOX/NEW OFFICES "           => ".NEW OFFICES " "INBOX/NEW OFFICES "           => ".NEW OFFICES "
 </file> </file>
 +
 +:!: **NOTICE**: The translated name of a sub-subfolder contains the original **directory separator** (.e.g. ''.Archives/2013''), this is OK because offlineimap3 is aware of the differencies in directory separator from the IMAP surce (the "/" is detected automatically) and the destination Mailird ("." is the default). So the destination folder is correctly created as ''.Archives.2013''.
 +
 +===== The configuration file =====
 +
 +<file>
 +[general]
 +accounts = CopyFromIMAP
 +
 +[Account CopyFromIMAP]
 +remoterepository = OldServer
 +localrepository = NewServer
 +
 +[Repository OldServer]
 +type = IMAP
 +nametrans = lambda foldername: re.sub(r'^\.INBOX$', '', '.' + re.sub(r'^INBOX/', '', foldername.replace('.', '_')))
 +remotehost = mail.oldserver.com
 +remoteuser = username@oldserver.com
 +remotepass = MySecret
 +createfolders = False
 +
 +[Repository NewServer]
 +type = Maildir
 +localfolders = /home/username/Maildir
 +</file>
 +
 +===== Web References =====
 +
 +  * **[[https://github.com/OfflineIMAP/offlineimap3/blob/master/offlineimap.conf|offlineimap.conf]]**
  
doc/appunti/linux/sa/offlineimap3_nametrans.txt · Last modified: 2024/03/22 11:23 by niccolo