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

Tobias Eigen tobias at kabissa.org
Tue May 11 22:16:00 EEST 2004


Dear Lefteris and Gautam, 

Many thanks for this response. I'll wait until the next stable version of
imapfilter is released then try these out. 

Do either of these examples check that the message ID is unique? 

Best wishes, 

Tobias

-- 
Tobias Eigen
Executive Director

Kabissa - Space for change in Africa
http://www.kabissa.org

* Kabissa, meaning complete in Kiswahili, was founded on the belief that 
information and communications technologies (ICTs) can be a revolutionary 
force in civil society. * 


Quoting Lefteris Chatzibarbas <lefcha at hellug.gr>:

> On Tue, May 11, 2004 at 02:41:54PM +1000, Gautam Gopalakrishnan wrote:
> > 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.
> >
> > [...]
> >
> > 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
> 
> Here is another way to do this:
> 
> 	results = match(acc1, 'INBOX', {})
> 	hdrs = fetchheaders(acc1, 'INBOX', { 'List-Id' }, results)
> 
> 	for msgid, msghdr in pairs(hdrs) do
> 		_, _, listname = string.find(msghdr, "<([%w_.-]+)>")
> 		if listname ~= nil then
> 			print(msgid, listname)
> 	--		move(acc1, 'INBOX', acc1, listname, { msgid })
> 		end
> 	end
> 
> Of course, if all goes well, comment print() and uncomment move().
> 
> 





More information about the Imapfilter-devel mailing list