[imapfilter-devel] interest in filter mailing lists on unknown names

Per Westerlund perw at gbg.dimension.se
Tue May 11 11:36:04 EEST 2004


I have not tried your example, nor read up on lua, but there is one 
thing that to me looks like a problem.

If you are using indices to address your messages, I think they are 
changed when you perform a "move", everything later in the mailbox will 
be logically reindexed.

Two ways to fix this:

1) make sure you handle messages from higher numbered to lower numbered.

2) Use unique message numbers instead, then it does not matter that they 
are reordered. It also protects against someone else modifying the 
mailbox at the same time, or several instances of the same program at 
once. Set:

	options.uid = true


/Per Westerlund

Gautam Gopalakrishnan wrote:

> On Thu, May 06, 2004 at 05:41:51PM -0400, Tobias Eigen wrote:
> 
>>Hi, 
>>
>>I've just started playing with imapfilter and am very pleased with its
>>functionality, esp for filtering lists into subfolders automatically. 
>>
>>I'm interested in the functionality described in this thread titled "filter
>>mailing lists on unknown names" -
>>http://lists.hellug.gr/pipermail/imapfilter-devel/2004/000512.html
> 
> 
> Hey,
> 
> I've always wanted to do this with procmail on my POP mail, didn't
> know how to. Anyway, here's some code I wrote. It almost works.
> Anybody with more skill in Lua could maybe help out here. The
> filter runs for only half of my messages. Looks like something to do
> with table.foreachi, but I can't figure it out.
> 
> As usual, no guarantees. To be safe, you could change move() to copy().
> Also, if you want to filter based on the subject having [listname],
> it's trivial to change the regex in function and the fetchheader line
> 
> Any feedback is welcome.
> 
> Cheers
> Gautam
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> options.timeout = 120
> options.subscribe = true
> options.info = true
> options.create = true
> options.expunge = true
> 
> acc1 = {
> 	server = '*',
> 	username = '*',
> 	password = '*',
> 	ssl = 'ssl3',
> }
> 
> function filter_listid(k, v) 
> 	hdr = fetchheaders(acc1, 'INBOX', {'List-Id'}, {v})
> 	if hdr[v] == nil then return nil end
> 	hdr[v] = string.gsub(hdr[v], "[\n\r]", "")
> 	if hdr[v] == "" then return nil end
> 	z, z, listname = string.find(hdr[v], "<([a-zA-Z0-9_.-]-)>", 1)
> 	if listname == nil then return nil end
> 	move(acc1, 'INBOX', acc1, listname, {v})
> 	return nil
> end
> 
> f_all  = {}
> 
> results = match(acc1, 'INBOX', f_all)
> if results ~= nil
> then
> 	table.foreachi(results, filter_listid)
> end
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Imapfilter-devel mailing list
> Imapfilter-devel at lists.hellug.gr
> http://lists.hellug.gr/mailman/listinfo/imapfilter-devel




More information about the Imapfilter-devel mailing list