[imapfilter-devel] move/copy problem

Michael M. Tung michael.m.tung at gmail.com
Thu Jul 1 22:55:21 EEST 2010


Hi all,

I found a work around to my previous problem, which nevertheless I still don't
understand since the copy_messages command in the old script erroneously reports
that files are copied.

Now I am using the following code

------------------------------------------------------------------------

all = myserver.INBOX:select_all()
spam = Set {}
unsure = Set {}
  for _, mesg in ipairs(all) do
	mbox, uid = unpack(mesg)
	text = mbox[uid]:fetch_message()
	flag = pipe_to('bogofilter', text)
	if (flag == 0) then
	  table.insert(spam, mesg)
        elseif (flag == 2) then
          table.insert(unsure, mesg)
        end
  end

myserver['INBOX']:move_messages(myserver['Junk'], spam)
myserver['INBOX']:copy_messages(myserver['Junk/Unsure'], unsure)

------------------------------------------------------------------------

However, I am running exactly this same config on two different machines
(with identical versions IMAPFilter 2.2.2, bogofilter v1.2.1 and
Oracle Berkeley db 4.7.25). On one machine it works as expected and the
other machine gives the error:

imapfilter: bogotest5.lua:26: required argument left out

Line 26 is the line containing "flag = pipe_to('bogofilter', text)".
What is going wrong here???

Any hint to solve this mystery is appreciated.
Best,
      Mike


Michael M. Tung [michael.m.tung at gmail.com] wrote:
> Hi everybody,
> 
> I am quite desperate in getting an imapfilter script to move and copy my
> mail with a bogofilter pipe. The following code is based from somewhere
> on the web (obviously I don't include the account definitions):
> 
> ------------------------------------------------------------------------
> results = mymailserver.INBOX:select_all()
> spam = {}
> unsure = {}
> text = mymailserver.INBOX:fetch_message(results)
> if (text ~= nil ) then
>   for msgid, msgtxt in pairs(text) do
>         exitstatus = pipe_to('bogofilter', msgtxt)
>         if (exitstatus == 0) then
>           table.insert(spam, msgid)
>         elseif (exitstatus == 2) then
>           table.insert(unsure, msgid)
>         end
>   end
>   print( string.format("%d messages in 'INBOX' classified SPAM", table.getn(spam)) )
>   print( string.format("%d messages in 'INBOX' classified UNSURE", table.getn(unsure)) )
>   mymailserver.INBOX:move_messages(upv['Junk'], spam)
>   mymailserver.INBOX:copy_messages(upv['Junk/Unsure'], unsure)
> else
>   print( "found no messages in 'INBOX'" )
> end
> ------------------------------------------------------------------------
> 
> Running it seems O.K. The output is something like:
> 
> 0 messages in 'INBOX' classified SPAM
> 5 messages in 'INBOX' classified UNSURE
> 5 messages copied from user at mymailserver/INBOX to user at mymailserver/Junk/Unsure.
> 
> However, nothing actually happens on the IMAP server. I tried this on
> several of my accounts, but without success.
> 
> I can't really see what is going on. Can you please help?
> 
> Thanx. Best, Mike
> 


More information about the Imapfilter-devel mailing list