[imapfilter-devel] documentation error sample.extend.lua.txt
Pierre Antoine
pierre.antoine at acm.org
Mon Oct 1 20:39:12 EEST 2007
sample.extend.lua.txt :
****
-- IMAPFilter can take advantage of all those filtering utilities that
-- are available and use a wide range of heuristic tests, text analysis,
-- internet-based realtime blacklists, advanced learning algorithms,
-- etc. to classify mail. IMAPFilter can pipe a message to a program
-- and act on the message based on the program's exit status.
--
-- The auxiliary function pipe_to() is supplied for conveniency. For
-- example if there was a utility named "bayesian-spam-filter", which
-- returned 1 when it considered the message "spam" and 0 otherwise:
result = myaccount.mymailbox:select_all()
messages = myaccount.mymailbox:fetch_message(result)
result = {}
for msgid, msgtxt in pairs(messages) do
if (pipe_to('bayesian-spam-filter', msgtxt) == 1) then
table.insert(result, msgid)
end
end
myaccount.mymailbox:delete_messages(result)
***
This code do not work as expected.
delete_messages(table) : table is an array of boolean values.
Replace
table.insert(result, msgid)
with
result[msgid]=true
Empty array should also be checked, but it is ok, it is just a simple
sample.
--
Pierre Antoine
More information about the Imapfilter-devel
mailing list