{"action":"opened","issue":{"url":"https://api.github.com/repos/OfflineIMAP/offlineimap/issues/230","labels_url":"https://api.github.com/repos/OfflineIMAP/offlineimap/issues/230/labels{/name}","comments_url":"https://api.github.com/repos/OfflineIMAP/offlineimap/issues/230/comments","events_url":"https://api.github.com/repos/OfflineIMAP/offlineimap/issues/230/events","html_url":"https://github.com/OfflineIMAP/offlineimap/issues/230","id":103147018,"number":230,"title":"Working example script with spam filter?","user":{"login":"dpo","id":38760,"avatar_url":"https://avatars.githubusercontent.com/u/38760?v=3","gravatar_id":"","url":"https://api.github.com/users/dpo","html_url":"https://github.com/dpo","followers_url":"https://api.github.com/users/dpo/followers","following_url":"https://api.github.com/users/dpo/following{/other_user}","gists_url":"https://api.github.com/users/dpo/gists{/gist_id}","starred_url":"https://api.github.com/users/dpo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpo/subscriptions","organizations_url":"https://api.github.com/users/dpo/orgs","repos_url":"https://api.github.com/users/dpo/repos","events_url":"https://api.github.com/users/dpo/events{/privacy}","received_events_url":"https://api.github.com/users/dpo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-26T00:59:55Z","updated_at":"2015-08-26T00:59:55Z","closed_at":null,"body":"I've been trying to get bogofilter to append a spam header to my incoming messages without success. I just can't find an example out there that explains how to set up spam filtering when e-mail is fetched with `offlineimap`. I'm not running an e-mail server. I'm simply synchronizing several IMAP accounts locally. I use Mutt to read messages. All is well except for spam filtering.\r\n\r\nHere's what I tried. I installed bogofilter and in my `~/.offlineimaprc`, I have\r\n```\r\npostsynchook = ~/bin/process-new-mail ~/Mail/Account1\r\n```\r\n\r\nIn `~/bin/process-new-mail`, I have\r\n```\r\ncheck_spam() {\r\n  # Protect against paths with white space\r\n  SAVEIFS=$IFS\r\n  IFS=$(echo -en \"\\n\\b\");\r\n  new=$(find $1/INBOX/new -type f)\r\n  for f in $new\r\n  do\r\n    bogofilter -u -p -I $f -O $1/INBOX-processed/new/$(basename $f)\r\n  done\r\n  IFS=$SAVEIFS\r\n}\r\n\r\ncheck_spam $1\r\n```\r\n\r\nThe main idea is that `offlineimap` places new email in `~/Mail/Account1/INBOX/new`. Bogofilter will look for it there and place processed files in `~/Mail/Account1/INBOX-processed/new`. Mutt will look for new messages in the latter location.\r\n\r\nIf I run `~/bin/process-new-mail ~/Mail/Account1` from the command line, all is well. But if the script is run from `offlineimap`'s `postsynchook`, there's only garbage in the output location. Mutt can't make sense of it and locks up.\r\n\r\nCould anyone share a working setup?"}}