# [SOLVED] getmail and sa-learn in a virtual mail server

## mimosinnet

I am trying to use sa-learn with getmail in a virtual mail server. I have managed to get it working with the following configuration:

```
[retriever]

type = SimpleIMAPSSLRetriever

server = server

port = 52003

username = username 

password = password

mailboxes = ("IN.Spam_Fallat",)

[filter-learn]

type = Filter_classifier

path = /usr/bin/sa-learn

user = root

group = root

arguments = ("--spam","-u","root")

allow_root_commands = true

[destination]

type = MDA_external

path = /usr/libexec/dovecot/deliver

user = mail

group = mail

arguments = ("-d","destination@mail.org","-m","IN.Spam")

[options]

verbose = 0

delete = true

message_log = ~/.getmail/log

read_all = true
```

I have used these references: getmail documentation, this post and this information from spamassassin.

I have the bayes database in the root of my virtual mail system: /var/spool/mail/.spamassassin/

```
# ls /var/spool/mail/.spamassassin/

auto-whitelist  auto-whitelist.mutex  bayes.mutex  bayes_seen  bayes_toks  user_prefs
```

and in the root user:

```
# ls /root/.spamassassin/

auto-whitelist  auto-whitelist.mutex  bayes.mutex  bayes_seen  bayes_toks  user_prefs
```

If I change the user root by the user mail in the filter section, I get this type of "permission denied" error:

```
bayes: locker: safe_lock: cannot create lockfile /root/.spamassassin/bayes.mutex: S’ha denegat el permís
```

I have found this thread that suggests changing the permissions of bayes.mutex file, but I have been unable to get rid of the error unless I change the user to root. Also, I believe sa-learn should use the .spamassasin folder in /var/spool/mail instead of the one in /root.

Any hints appreciated. Thanks for your attention.

Cheers!

---

Update: the --dbpath option solved the issue. Now I have: 

[retriever]

type = SimpleIMAPSSLRetriever

server = server 

port = 52003

username = username 

password = password

mailboxes = ("IN.Spam_Fallat",)

[destination]

type = MDA_external

path = /usr/bin/sa-learn

user = mail

group = mail

arguments = ("--dbpath","/var/spool/mail/.spamassassin","--spam")

[options]

verbose = 0

delete = true

message_log = ~/.getmail/log

read_all = true

Just writing the message in the forums solves it!   :Laughing: 

Wonderful gentoo...   :Laughing:   :Laughing: 

Thanks!

----------

