[imapfilter-devel] Generic rules?

Andrei POPESCU andreimpopescu at gmail.com
Tue Sep 30 12:21:25 EEST 2014


On Jo, 25 sep 14, 09:32:50, Joe MacDonald wrote:
> [[imapfilter-devel] Generic rules?] On 14.09.25 (Thu 02:18) Andrei POPESCU wrote:
> > 
> > Since I'm subscribed to many lists on the same server and I might 
> > subscribe/unsubscribe some lists from time to time with maildrop I use 
> > rules like this:
> > 
> > 
> >     # These are the lists.debian.org lists
> >     if (/^List-Id:.*<debian-(.*)\.lists.debian.org>/)
> >         to Maildir/.debian.$MATCH1/
> > 
> > 
> > but I can't figure out how to do this with imapfilter (if possible).
> 
> It is possible, to a degree.  I have something very much like this in my
> config.lua:
> 
>    msgs = dn.INBOX:contain_field('List-id', 'users.list.opensaf.org') +
>           dn.INBOX:contain_field('List-id', 'bod.list.opensaf.org') +
>           dn.INBOX:contain_field('List-id', 'openais.lists.linux-foundation.org'))
>    [...]
>    dn.INBOX:move_messages(dn['SAF'], msgs)
 
I might be totally misunderstanding what you're doing here, but I don't 
think this is what I need.

> https://github.com/lefcha/imapfilter/issues/45

Based on the code in that issue I came up with:

    list_msgs = gmx.INBOX:contain_field('List-Id', 'lists.debian.org')

    for _, msg in ipairs(list_msgs) do
        mailbox, uid = table.unpack(msg)
        print(mailbox)
        print(uid)
        print(msg)
        list_id = mailbox[uid]:fetch_field('List-Id')
        print(list_id)
        list = string.match(list_id, '<(.*-.*)%.lists%.debian%.org>')
        print(list)
        folder = list:gsub('-', '/')
        print(folder)
        mailbox[uid]:move_messages(gmx[folder])
    end

but I get:

$ imapfilter
table: 0x1a535c8
395262
table: 0x1a6b1e8
Fetched field "List-Id" of xxxxxxx at gmx.com@imap.gmx.com/INBOX[395262].
List-Id: <debian-publicity.lists.debian.org>
debian-publicity
debian/publicity
imapfilter: /home/amp/.imapfilter/config.lua:39: attempt to call method 'move_messages' (a nil value)

I'm sure my error is obvious to someone familiar with lua or imapfilter, 
but I am neither. Could you please help?

Thanks,
Andrei
-- 
http://nuvreauspam.ro/posts/2010/neticheta-pe-mail/
http://nuvreauspam.ro/gpg-transition.txt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.hellug.gr/pipermail/imapfilter-devel/attachments/20140930/ab253681/attachment.sig>


More information about the Imapfilter-devel mailing list