[imapfilter-devel] move/copy problem

Michael M. Tung michael.m.tung at gmail.com
Tue Jun 29 16:14:09 EEST 2010


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