Skip to content

Instantly share code, notes, and snippets.

@adam-stokes
Created June 11, 2013 17:14
Show Gist options
  • Save adam-stokes/5758764 to your computer and use it in GitHub Desktop.
Save adam-stokes/5758764 to your computer and use it in GitHub Desktop.
Using imapfilter to pipe messages through bogofilter
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)
@adam-stokes
Copy link
Author

Taken from a forum somewhere, haven't tested nor do I hold any copyrights on this. If someone can find a link to it post it here for reference back to the original author.

@squiddle
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment