[imapfilter-devel] Re: can't solve "table expected, got nil"
David DeSimone
fox at verio.net
Wed Aug 18 02:10:27 EEST 2004
Joel CARNAT <joel at carnat.net> wrote:
>
> > You should rewrite it like this:
> >
> > results = match(admin, 'INBOX', nagios)
> >
> > if (results ~= nil)
> > then
> > move(admin, 'INBOX', admin, 'nagios', results)
> > end
>
> How comes this is not the default behaviour ?
> I mean, isn't possible to tell imapfilter to not execute ACTION if
> RESULTS is nil ?
Well, that is exactly what it says... if the results are nil, don't do
the ACTION.
> I have about 20 rules and wouldn't like to have to add the whole
> if,then,end for each :)
Well, in that case, you can modify imapfilter. It seems that much of
imapfilter's code is written in lua, so you can change it if you wish.
You can find the move() routine in /usr/share/imapfilter/interface.lua
(at least, that's where it is on my install):
It would be pretty simple add a line after all the "checktype"
statements that says
if (messages == nil)
then
return nil
end
However, I think you would be better served if you just wrote your own
function, and it would also reduce the amount of repetition in your own
script. For example:
function delete_matching(account, mbox, query)
results = match(account, mbox, query)
if (results ~= nil)
then
delete(account, mbox, results)
end
end
Then you can just call delete_matching() 20 times with your 20 queries.
You know... I think I will do this in my configuration, as I have a lot of
these if-statements, too. :)
> Then... now the whole filtering process goes on well, but...
> my MATCH doesn't seem to work on the account where NIL is returned.
I have had quite some trouble using "body" matches with my IMAP server.
I don't know if that's the trouble you are having. But I find that if I
specify a search clause like 'body "on firewall02,"' it will not match,
whereas a clause like 'body "firewall02,"' will match. And yet, the
email that matches contains this line:
Error on firewall02,
In this case it seems to be the IMAP server that is failing to find the
match, because I tested with a different IMAP server and could not
duplicate the problem. I don't know why the IMAP server silently
ignores queries that contain spaces.
That may or may not be related to the problem you are describing. I'm
afraid I don't understand the problem...
--
David DeSimone || Network Admin || fox at verio.net
"It took me fifteen years to discover that I had no
talent for writing, but I couldn't give it up because
by that time I was too famous. -- Robert Benchley
More information about the Imapfilter-devel
mailing list