spam filtering with bogofilter

66 views
Skip to first unread message

Gour

unread,
Apr 14, 2015, 1:29:11 AM4/14/15
to mu-di...@googlegroups.com
Hello,

I'm trying to modify functions for registering mail as spam/ham with
Spamassassin posted in the list some time ago, to work with Bogofilter spam
filter...

The code looks as follows:

;; handling spam with Bogofilter
(defun mark-message-as (type)
(let* ((path (mu4e-message-field-at-point :path))
(command (format "/usr/bin/bogofilter %s < %s" type path)))
(shell-command command)))

(defun mark-message-as-spam ()
(interactive)
(mark-message-as "-s")
(mu4e~proc-move (mu4e-message-field-at-point :message-id) "../spam"))

(defun mark-message-as-ham ()
(interactive)
(mark-message-as "-n")
(mu4e~proc-move (mu4e-messsage-field-at-point :message-id) "../inbox"))

(add-to-list 'mu4e-headers-actions
'("Mark as spam" . mark-message-as-spam) t)

The first problem which I encounter is that when I invoke
mark-message-as-spam, I can confirm that the Bogofilter's wordlist.db is
updated, but at the end I get:

mu4e-error: [mu4e] Target dir does not exist

and in Messages buffer I also see the line:

(Shell command succeeded with no output)

My setup looks as follows:

(setq mu4e-maildir "~/Maildir")

and the multiple accounts are setup as:

(defvar my-mu4e-account-alist
'(("gour"
(msmtp-account "gour")
(mu4e-sent-folder "/gour/sent")
(mu4e-drafts-folder "/gour/drafts")
(mu4e-trash-folder "/gour/trash")
(mu4e-refile-folder "/archive")
(user-mail-address "go...@atmarama.net")
(user-full-name "Gour")
(mu4e-compose-signature-auto-include t)
(message-cite-reply-position above)
(message-cite-style message-cite-style-outlook))
...
))

There is e.g. ~/Maildir/gour/spam folder, so I do not have clue why there is
error saying the 'Target dir does not exist' ?

Another problem is that despite having "Mark as spam" action added as header
actions (it's according to the
http://www.djcbsoftware.nl/code/mu/mu4e/Adding-an-action-in-the-headers-view.html
doc), still it's not listed in the Headers menu withing mu4e?

Any help is welcome...


Sincerely,
Gour

--
In this endeavor there is no loss or diminution,
and a little advancement on this path can protect
one from the most dangerous type of fear.

Dirk-Jan C. Binnema

unread,
Apr 14, 2015, 5:17:41 AM4/14/15
to mu-di...@googlegroups.com

On Tuesday Apr 14 2015, Gour wrote:

> Hello,
>
> I'm trying to modify functions for registering mail as spam/ham with
> Spamassassin posted in the list some time ago, to work with Bogofilter spam
> filter...

Better not use any internal (mu4e~...) functions; there are all kinds of
subtleties, so those are specifically not meant for use in user
functions.

I'd recommend creating a mu4e headers action instead
(`mu4e-headers-actions').

Cheers,
Dirk.
--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C

Gour

unread,
Apr 16, 2015, 2:24:28 AM4/16/15
to mu-di...@googlegroups.com

Dirk-Jan C. Binnema <dj...@djcbsoftware.nl> writes:

> Better not use any internal (mu4e~...) functions; there are all kinds of
> subtleties, so those are specifically not meant for use in user functions.

Ahh, thank you for pointing it out...Learning something new. ;)

> I'd recommend creating a mu4e headers action instead
> (`mu4e-headers-actions').

Is it possible to e.g. use. mu4e-header-mark-for-move and pass the
destination folder as parameter?

Any example would be useful...


Sincerely,
Gour

--
An intelligent person does not take part in the sources of misery,
which are due to contact with the material senses. O son of Kuntī,
such pleasures have a beginning and an end, and so the wise man does
not delight in them.

Dirk-Jan C. Binnema

unread,
Apr 16, 2015, 2:26:23 PM4/16/15
to mu-di...@googlegroups.com

On Thursday Apr 16 2015, Gour wrote:

> Dirk-Jan C. Binnema <dj...@djcbsoftware.nl> writes:
>
>> Better not use any internal (mu4e~...) functions; there are all kinds of
>> subtleties, so those are specifically not meant for use in user functions.
>
> Ahh, thank you for pointing it out...Learning something new. ;)
>
>> I'd recommend creating a mu4e headers action instead
>> (`mu4e-headers-actions').
>
> Is it possible to e.g. use. mu4e-header-mark-for-move and pass the
> destination folder as parameter?
>
> Any example would be useful...
>

Something like this might work:

(defun my-mark-as-spam ()
"Mark as spam."
(interactive)
;; do bogofilter stuff
(mu4e-mark-at-point 'move "/spam"))

Cheers,
Dirk.

Gour

unread,
Apr 17, 2015, 2:37:18 AM4/17/15
to mu-di...@googlegroups.com

Dirk-Jan C. Binnema <dj...@djcbsoftware.nl> writes:

> Something like this might work:
>
> (defun my-mark-as-spam ()
> "Mark as spam."
> (interactive)
> ;; do bogofilter stuff
> (mu4e-mark-at-point 'move "/spam"))

Thank you.

Considering that I have multi-accounts setup, I wonder if there is an easy
way to move message to the spam folder belonging to each account,
iow. /Maildir/account-x/spam, or I should be satisfied to simply create
common spam folder and move everything ther as in the above example?


Sincerely,
Gour

--
One who is able to withdraw his senses from sense objects,
as the tortoise draws its limbs within the shell,
is firmly fixed in perfect consciousness.

Reply all
Reply to author
Forward
0 new messages