More details on folder translator function

Thomas Kahle tomka at gentoo.org
Thu Jan 13 07:51:22 UTC 2011


Hi,

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:

pythonfile=~/bin/offlineimap-helpers.py

Then some account might look like this

[Repository acc1remote]
type = IMAP
remotehost = imap.acc1.com
remoteusereval = get_username("imap.acc1.net")
remotepasseval = get_password("imap.acc1.net")
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"
    else:
        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:

http://dev.gentoo.org/~tomka/mail.html

Cheers,
Thomas

-- 
Thomas Kahle
http://dev.gentoo.org/~tomka/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 316 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/offlineimap-project/attachments/20110113/23368cab/attachment.pgp>


More information about the OfflineIMAP-project mailing list