[imapfilter-devel] interest in filter mailing lists on unknown names
Gautam Gopalakrishnan
gautam.gopalakrishnan at its.monash.edu.au
Tue May 11 07:41:54 EEST 2004
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
-------------- next part --------------
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
More information about the Imapfilter-devel
mailing list