# Spamassassin - Create mail filters per mailbox

**URL:** <https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165>\
**Category:** Virtualmin\
**Created:** [August 15, 2023, 11:56am UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165 "2023-08-15T11:56:30Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ADDISON74](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@ADDISON74](https://forum.virtualmin.com/u/ADDISON74)\
**Post date:** [August 15, 2023, 11:56am UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165/1 "2023-08-15T11:56:30Z")

</div>

According to the user manual, the SpamAssassin client can be set as **spamassassin** (standalone) or **spamc** (client for SA filter server spamd). When the last one is used, it only reads the global configuration.

Virtualmin offers the possibility to use preferences per virtual server. In this case **spamassassin** must be set as the client. There is an **Allow mailbox users to create mail filters** option in the **Virtualmin \> Email Settings \> Spam and Virtus Scanning** section.

How does this option work at the mailbox level? Which files are responsible after it is enabled. If this is the only responsible file **/home/domain/.spamassassin/user\_prefs** , it applies to all mailboxes not at the individual mailbox level.

If I go to **Virtualmin \> Services \> SpamAssassin Configuration** and I would like to edit the configuration file it opens this file /**etc/webmin/virtual-server/spam/[numbers]/virtualmin.cf**. What is the scope of the **user\_prefs** file in this case?

---

<div class="post-metadata">

**Author:** ![ADDISON74](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@ADDISON74](https://forum.virtualmin.com/u/ADDISON74)\
**Post date:** [August 15, 2023, 4:29pm UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165/2 "2023-08-15T16:29:43Z")

</div>

The individual user configuration file is called **user\_prefs** and is located in the user’s home directory in the .spamassassin subdirectory. The ability for individual users to have their own user\_prefs is a tunable parameter.

According to the SpamAssassin documentation, there is a descending precedence of configuration files that SA considers when starting/restarting:

**/usr/share/spamassassin**  
**/etc/mail/spamassassin**  
**/home/[user]/.spamassasin/user\_prefs**

in which the last one wins.

Virtualmin comes with its own configuration file

**/etc/webmin/virtual-server/spam/[vm\_number]/**

Is this path considered and if so, is it the last one?

I made an attempt and modified the **user\_prefs** file setting the score to the value 1. I restarted the service, but it was not taken into account, the files considered spam used the default value 5.

If I can’t find an explanation how the files from configuration I will set the score in each one at a different value and I will identify the order in which they are retrieved.

---

<div class="post-metadata">

**Author:** ![ksihota](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/ksihota/32/1634_2.png) [@ksihota](https://forum.virtualmin.com/u/ksihota)\
**Post date:** [August 15, 2023, 5:32pm UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165/3 "2023-08-15T17:32:54Z")

</div>

From what I can tell on my setup,  
**/etc/webmin/virtual-server/spam/[vm\_number]/**  
is the .cf that defines the vs spam settings and the  
**/home/[user]/.spamassasin/user\_prefs**  
is the .cf that defines an individual user’s settings

On mine the individual user’s settings overrides the others I believe.  
You might want to check it to be sure because it gets pretty confusing

---

<div class="post-metadata">

**Author:** ![ADDISON74](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@ADDISON74](https://forum.virtualmin.com/u/ADDISON74)\
**Post date:** [August 15, 2023, 5:48pm UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165/4 "2023-08-15T17:48:00Z")

</div>

The **local.cf** files created in the **/etc/webmin/virtual-server/spam/[machine\_id]** directories are actually symbolic links to **/etc/spamassassin/local.cf**. Basically we have a common configuration for all virtual servers. The difference appears through the values set in **virtualmin.cf** that exist for each individual server, the only one having the permission from the domain owner.

---

<div class="post-metadata">

**Author:** ![ADDISON74](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@ADDISON74](https://forum.virtualmin.com/u/ADDISON74)\
**Post date:** [August 15, 2023, 5:55pm UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165/5 "2023-08-15T17:55:24Z")

</div>

Finally, I came to a conclusion after tests. The file

**/home/[user]/.spamassassin/user\_prefs**

applies to the owner of the virtual server and not to the email addresses that belong to the domain.

Virtualmin is able to create a **/.spamassassin/user\_prefs** file for each email address based on that option in the UI set to Yes, but they will have to be edited manually, since they are not detected in the interface, in the server configuration.

If **Allow mailbox users to create mail filters** option in the **Virtualmin \> Email Settings \> Spam and Virtus Scanning** section is set to No, do not edit **user\_prefs** expecting to change the SpamAssassin values for your mailboxes (all at onces). This only applies to the domain owner email address.

---

<div class="post-metadata">

**Author:** ![ksihota](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/ksihota/32/1634_2.png) [@ksihota](https://forum.virtualmin.com/u/ksihota)\
**Post date:** [August 15, 2023, 5:55pm UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165/6 "2023-08-15T17:55:36Z")

</div>

I set my Server .cf setup in Webmin, my VS .cf in Virtualmin and the VS user .cf in Usermin  
The only weird thing I noticed was the default setting for each of the areas always displays Default(5) which is not really accurate since if you change the setting one level up the Default setting for the lower level should now be that number.  
Example: Server set to 5  
VS Default should be 5  
VS set to 4  
User Default should now be 4 but it still defaults to 5 which is misleading

 ![image](https://cdn.forum.virtualmin.com/uploads/default/original/2X/8/8fca79fc504811707f704de2e71204de949ba76c.png)

---

<div class="post-metadata">

**Author:** ![ksihota](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/ksihota/32/1634_2.png) [@ksihota](https://forum.virtualmin.com/u/ksihota)\
**Post date:** [August 15, 2023, 6:05pm UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165/7 "2023-08-15T18:05:44Z")

</div>

When you say edited manually does that mean that editing in Usemin will do that?  
I will have to check this since I believe I have only checked using the domain owner email account.  
However, I would think that if you are not allowing users to change the SA rules (set to No) that it should apply to all settings in Usermin. A domain owner can set whatever they want in Virtualmin. I was only using the setting in Usermin to figure out how the system was working. What I do find odd is that if the setting is disabled for individual users in Virtualmin, why would the option be available or even visible in Usermin.

---

<div class="post-metadata">

**Author:** ![ADDISON74](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@ADDISON74](https://forum.virtualmin.com/u/ADDISON74)\
**Post date:** [August 15, 2023, 6:08pm UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165/8 "2023-08-15T18:08:18Z")

</div>

There is an order in which the values are retrieved, I showed it above. Basically there are 3 files that can set the SpamAssassin configuration. I created this post for information, because initially I thought that the **user\_prefs** file created in the **/home/domain\_owner** directory could modify the default values from the other two files for the domain, i.e. for all email addresses created. Well, it was only for the owner’s address, as individual changes were required per email address and not shared. Most likely I will use the values from **/etc/mail/spamassassin/local.cf** and I will not use individual configurations per email address, not offering this feature of editing especially as it could also be a security breach.

---

<div class="post-metadata">

**Author:** ![ADDISON74](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@ADDISON74](https://forum.virtualmin.com/u/ADDISON74)\
**Post date:** [August 15, 2023, 6:11pm UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165/9 "2023-08-15T18:11:11Z")

</div>

I have not checked what happens in Usermin, but in the Virtualmin interface the **user\_prefs** files that will be created in the directory of each email address can only be edited in File Manager or Terminal. This is the path where the **/home/[domain\_owner]/homes/[email\_address]/.spamassassin/** files will be created.

---

<div class="post-metadata">

**Author:** ![ksihota](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/ksihota/32/1634_2.png) [@ksihota](https://forum.virtualmin.com/u/ksihota)\
**Post date:** [August 15, 2023, 6:15pm UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165/10 "2023-08-15T18:15:13Z")

</div>

Just checked my settings and I do allow users to filter emails.

 ![image](https://cdn.forum.virtualmin.com/uploads/default/original/2X/7/73e2a184942b1edfd127966f414c49986d55c580.png)

I think its an important tool to help organize and cleanup mail. If this is not checked Procmail won’t have access to the file and no filtering will be done that is set up by the user.

I was thinking of another checkbox I saw in one of the dialogs which controlled the creation of SpamAssasin rules by individual users.

---

<div class="post-metadata">

**Author:** ![ksihota](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/ksihota/32/1634_2.png) [@ksihota](https://forum.virtualmin.com/u/ksihota)\
**Post date:** [August 15, 2023, 6:20pm UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165/11 "2023-08-15T18:20:01Z")

</div>

> [@ADDISON74](#):
>
> **/home/[domain\_owner]/homes/[email\_address]/.spamassassin/**

I think this might be the location that Usermin settings are applied to.

---

<div class="post-metadata">

**Author:** ![ADDISON74](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@ADDISON74](https://forum.virtualmin.com/u/ADDISON74)\
**Post date:** [August 15, 2023, 6:23pm UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165/12 "2023-08-15T18:23:15Z")

</div>

Until now I mostly solve SPAM using access tables in Postfix and proper configuration for all restrictions in their order. It was enough to reject SPAM with an RFC error and a client never came back. But when you have to deal with a huge number of messages per minute, it is not advisable to do everything in MTA. For this reason I hand over the tasks to SpamAssassin which, if properly configured, is an extremely powerful tool.

---

<div class="post-metadata">

**Author:** ![ADDISON74](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@ADDISON74](https://forum.virtualmin.com/u/ADDISON74)\
**Post date:** [August 15, 2023, 6:27pm UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165/13 "2023-08-15T18:27:37Z")

</div>

In this case Usermin is working as expected.

Configuring the values in **/home/[domain\_owner]/.spamassassin** as I did initially is wrong because it does not apply to all email addresses created in that domain, but only to the domain\_owner’s address. This was the case without setting **Allow mailbox users to create mail filter** to Yes.

There are discussions over the time I found searching the Internet, but none of them have reached a conclusion.

---

<div class="post-metadata">

**Author:** ![ADDISON74](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@ADDISON74](https://forum.virtualmin.com/u/ADDISON74)\
**Post date:** [August 15, 2023, 6:34pm UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165/14 "2023-08-15T18:34:17Z")

</div>

Another situation that I need to check is related to the situation in which the value in the UI for **Allow mailbox users to create mail filters** is set to No, because the files created when the value was Yes are not deleted, but remain in place.

Are these files still taken into account or not? If SpamAssassin takes into account their existence (as I think it happens) then it is not good. They should be deleted, but that would mean their loss forever.

---

<div class="post-metadata">

**Author:** ![ksihota](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/ksihota/32/1634_2.png) [@ksihota](https://forum.virtualmin.com/u/ksihota)\
**Post date:** [August 15, 2023, 7:18pm UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165/15 "2023-08-15T19:18:25Z")

</div>

I am having issues with the function as it appears to impact 2 different things.  
Its under Spam and Virus Scanning but appears to impact ALL mail filters

 ![image](https://cdn.forum.virtualmin.com/uploads/default/original/2X/7/70adb37e61498e1d9786777c54432925af900219.png)  
According to the help by selecting **No** it blocks access to the .procmailrc files  
I believe this is where all the mail filter rules are stored.  
Maybe it also blocks the local.cf file for the individual users’ spam settings?.

What happens when you want one but not the other. Filters may or may not have to do with Spam or viruses. Some additional information around how this works would certainly be helpful.

I am not quite sure why the filter stuff should be under the Spam and Virus heading.

---

<div class="post-metadata">

**Author:** ![ADDISON74](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@ADDISON74](https://forum.virtualmin.com/u/ADDISON74)\
**Post date:** [August 15, 2023, 8:09pm UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165/16 "2023-08-15T20:09:25Z")

</div>

If it is set to No, then SpamAssassin will take into account two configuration files, which it accesses in order from top to bottom

**/usr/share/spamassassin/local.cf**  
**/etc/mail/spamassassin/local.cf**

The **local.cf** files in **/etc/webmail/virtual-server/spam/[vm\_id]/** are actually symbolic links to **/etc/mail/spamassassin/** , so we have a single configuration for all of them.

If it is set to Yes, then the directory **/.spamassassin** is created in each mail box inside a virtual server. There are three files inside, including **local.cf** , which will be access last after the two previously mentioned before.

However, a configuration can be applied for each virtual server when the option is set to No, provided that the settings are added to the **virtualmin.cf** file (it can be edited in the Virtualmin user interface). For information, the configuration files in a directory are read by SpamAssassin in alphabetical order, priority being those that start with numbers.

---

<div class="post-metadata">

**Author:** ![ADDISON74](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@ADDISON74](https://forum.virtualmin.com/u/ADDISON74)\
**Post date:** [August 15, 2023, 9:33pm UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165/17 "2023-08-15T21:33:50Z")

</div>

After installing Virtualmin and creating a virtual server in the **/home/[domain]** directory, there is no .spamassassin directory.

If we go to the UI **Virtualmin \> Email Settings \> Spam and Virus Scanning** and choose the **Allow mailbox users to create mail filters** option, then the **/.spamassassin** directories are created for the domain itself and for each individual email address. This directory contains three files, including **user\_prefs** which is read last by SpamAssassin.

The order of reading the configuration files is from top to bottom in the following directories

**/usr/share/spamassassin**

**/etc/mail/spamassassin**

**/etc/webmin/virtual-server/spam/[vserver\_id]/**

(note: in this directory there are symbolic links to the directory above. there is still **virtualmin.cf** which is read last)

**/home/[domain]/homes/[email\_box]/.spamassassin/**

If in the meantime the previously mentioned option is set to No, the **/.spamassassin** directories remain created in **/home** , which is not right because SpamAssassin will still continue read the **user\_prefs** file and apply the configuration. I noticed this when I changed the score in the first two directories above, but the one in /home was always taken over.

Virtualmin has a bug and I will report it. When the option is reset to No, all **/.spamassassin** directories in /home/[domain] must be deleted.

---

<div class="post-metadata">

**Author:** ![ADDISON74](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/a/d07c76/32.png) [@ADDISON74](https://forum.virtualmin.com/u/ADDISON74)\
**Post date:** [August 15, 2023, 9:59pm UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165/18 "2023-08-15T21:59:02Z")

</div>

These tests were done in Debian 10. Now I discovered that in Debian 12 the .spamassassin directories are not created when the option is changed to Yes.

(still investigating before reporting as a new issue)

---

<div class="post-metadata">

**Author:** ![ksihota](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/ksihota/32/1634_2.png) [@ksihota](https://forum.virtualmin.com/u/ksihota)\
**Post date:** [August 15, 2023, 10:34pm UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165/19 "2023-08-15T22:34:54Z")

</div>

I’m using Centos 7.9

I just tested removing the SpamAssassin Mail Filter Module Webmin/Usermin Configuration/Avalable Modules

 ![image](https://cdn.forum.virtualmin.com/uploads/default/original/2X/0/00be3cf3887dbd05bee7d9e93596dad5650b99ee.png)  
And Yes, the menu item is now gone from Usermin, however, the SpamAssassin setting I had originally placed (3.5) is still active even though it is no longer available to the user and the VServer setting (set in Virtualmin) is set to 4. I think I would have to manually edit the user file to fix that.  
Just to check, I set the filter setting to No for users and sent another message and the Spam setting still indicates a Required\_Score of 3.5 which was the users setting not the VServer setting.  
If I manually edit the /home/vserver/homes/user/.spamassassin/user\_prefs file the changes are used by the system even though I have set the Allow mailbox users to create mail filters to No  
Another reason that I don’t think that item belongs under Spam and Virus scanning.  
 ![image](https://cdn.forum.virtualmin.com/uploads/default/original/2X/2/2b1f5fafa997281335160250c40a109b4cbabdd4.png)

As you pointed out the user\_pref file would have to be deleted, renamed or emptied. when the choice is changed.

It does do as the help points out and blocks the .procmailrc file in the users’ home directories so other filtering will not work

---

<div class="post-metadata">

**Author:** ![system](https://cdn.forum.virtualmin.com/uploads/default/original/2X/c/cd96d761e326db4b2bef94886a639109bd7a8e76.svg) [@system](https://forum.virtualmin.com/u/system)\
**Post date:** [August 23, 2023, 10:35pm UTC](https://forum.virtualmin.com/t/spamassassin-create-mail-filters-per-mailbox/122165/20 "2023-08-23T22:35:15Z")

</div>

Closed on August 23, 2023, 10:35pm UTC

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.
