More details on folder translator function

Thomas Kahle tomka at
Thu Jan 13 07:51:22 GMT 2011


On 10:07 Mon 10 Jan     , Philippe LeCavalier wrote:
> Hi.
> I'm trying to translate INBOX to INBOX.folder.subfolder so that all
> mails in the INBOX on one IMAP server get synced to subfolder on another
> IMAP server. I've managed to include/exclude all the folders I want on
> both sides but I can quite seem to translate the folder name.
> The INBOX on the recipient side is for another mail account so I don't
> want the mails merged.
> This is all I've come up with so far...
> nametrans = lambda foldername: re.sub('^INBOX\.', 'INBOX.folder.IN\.',
> foldername)
> Offlineimap isn't complaining with the above but it's not moving mail
> into the desired folder but rather simply moving mail from INBOX to
> INBOX which is exactly what I'm trying to avoid.

I'm using python for this.  You can specify a file with python
source code in your config as follows:


Then some account might look like this

[Repository acc1remote]
type = IMAP
remotehost =
remoteusereval = get_username("")
remotepasseval = get_password("")
nametrans = oimaptransfolder_acc1
ssl = yes

Note how nametrans is set to a function in the python file which looks
like this:

import re
def oimaptransfolder_acc1(foldername):
    if(foldername == "INBOX"):
        retval = "acc1"
        retval = "acc1." + foldername
    retval = re.sub("/", ".", retval)
    return retval

I hope this helps a little, I have quickly copied it from my guide on
offlineimap, mutt, etc. to be found here:


Thomas Kahle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 316 bytes
Desc: not available
URL: <>

More information about the OfflineIMAP-project mailing list