[imapfilter-devel] migrate one mailaccount to another one

Lefteris Chatzimparmpas lefcha at hellug.gr
Sun Nov 28 20:39:07 EET 2010


On 11/26/2010 03:41 PM, Ben Hartmann wrote:
> Hi there,
> 
> I'm new to imapfilter, but was able to migrate 120 filter rules from my
> thunderbird to an imapfilter-server-based-solution. The rules are all
> very basic which means for example:
> 
> --imapfilter-devel
> ImapFilterDevel = account_google.INBOX:contain_field('List-Id',
> 'imapfilter-devel.lists.hellug.gr')
> account_google.INBOX:move_messages(account_google['mailinglists/imapfilter-devel'],
> ImapFilterDevel)

Hello,

Since imapfilter 2.2 this can also be done (probably more elegantly)
like this:

ImapFilterDevel = account_google.INBOX:contain_field('List-Id', 'imapfilter-devel.lists.hellug.gr')
ImapFilterDevel:move_messages(account_google['mailinglists/imapfilter-devel'])


> Because everything works perfectly fine, I wonder if it's possible to
> use imapfilter for migrating imap accounts from server to server. With
> simple rules for every folder this is easy to achieve. But espacially
> with big folder structures this is a pain. So I'm looking for some sort
> of automatism to get all the folders (like a for loop over every folder...).

You should have a look at the list_all() and list_subscribed() methods
(see the imapfilter_config(5) man page).  They return a list of all or
just subscribed folders and mailboxes present in an account.

You can make them return all the mailboxes recursively for your mailbox,
eg

	mailboxes, _ = myaccount:list_all('', '*')
	for _, m in ipairs(mailboxes) do
	    print(m) // your code goes here
	end

The above code will just print the name of each mailbox on your account,
but you can do something more useful...


More information about the Imapfilter-devel mailing list