Auto-Learn spam/ham installer

We have sed for that. You search for a string in config, if it’s missing or if it’s there you can replace x by y or whatever you want…

1 Like

Apart from the sed command you can always backup the old config. This is an amazing addition.

It has helped a lot with cutting down my spam. I find everything else that brought up improve spam assassin but this is the only thing that really made a difference.

I took it as far as I could. Anyone with a little bit more advanced skill set than mine in this can do as they like included in Hestia.

I just figured be good to share it. Others might benefit.

Acept the pull request! :wink:

What if we use Junk instead of spam folder?

is just a case of editing the script to change the folder?

thanks

Can we use both?

By default, the junk and spam folders are the same!

1 Like

If you made it to the folder and their names in hestia You just switch them out in the script

Users put whatever folders they want, they migrate they rename folders, etc.

I think it’s safe to assume that any folder with spam, junk, no deseado, etc. Is in fact spam and should be treated as such regardless of the dovecot config.

1 Like

they why do i have 2 seperate folders both with different spam emails?

Note, dovecot put emails with —Spam— into same folder unless you edit file to put them in Junk

I am just asking to ensure that correct folder is read by auto learn for spam and ham.

thanks

Hi all.
I have a running hestiacp serving a few domains.
I have just added (post installation) sieve using /usr/local/hestia/install/upgrade/manual/install_sieve.sh

How can I go on to add the auto-learn spam/ham functionality that is being talked about here?
Where in github would I get the mentioned bash script and would I simply run it as root?

Cheers,
Kos

@djav1985 created a repository with the software here:

A couple of months ago I sent two PRs to fix two bugs and he merged them but are not in the main branch so if you install from his repo, you will have issues.

Till @djav1985 can add the fixes to main branch, you can download it from my fork (it has also a new feature ro remove duplicated spam/ham messages).

To install, using root user, execute these steps:

Note: If you don’t have git installed, install it with apt install git

cd /usr/local/src/
git clone https://github.com/sahsanu/v-hestiacp-sieve.git
cd v-hestiacp-sieve/
chmod +x installspam.sh
./installspam.sh

And that’s all.

Cheers,
sahsanu

2 Likes

Thank you very much, Sahsanu!

These are good instructions and I really appreciate your instant reply.

Cheers,
Kos

@sahsanu I get an error when I manually run the cronjob once (to test):

# bash /etc/cron.daily/spamham
find: ‘/var/mail/imapsieve_copy/{ham,spam}’: Datei oder Verzeichnis nicht gefunden

Should I change the find command in the file /etc/dovecot/sieve/scan_reported_mails from:

find "$SPOOL_DIR/{ham,spam}" -type f | xargs md5sum | sort -k1,1 | uniq -Dw32 \

to:

find "$SPOOL_DIR/ham" "$SPOOL_DIR/spam" -type f | xargs md5sum | sort -k1,1 | uniq -Dw32 \

?
__

# ll /var/mail/imapsieve_copy/
drwxrwsr-x mail mail 4.0 KB Wed Dec 21 15:05:38 2022  .
drwxrwsr-x mail mail 4.0 KB Wed Dec 21 14:55:50 2022  ..
drwxrwsr-x mail mail 4.0 KB Tue Jun 27 06:25:02 2023  ham
drwxrwsr-x mail mail 4.0 KB Wed Oct 25 14:17:10 2023  processing
drwxrwsr-x mail mail 4.0 KB Wed Oct 25 14:17:06 2023  spam
1 Like

I changed it in local but forgot to update repo. Remove quotes:

find $SPOOL_DIR/{ham,spam} -type f | xargs md5sum | sort -k1,1 | uniq -Dw32 \

or better, just use quotes surrounding variable SPOOL_DIR:

find "$SPOOL_DIR"/{ham,spam} -type f | xargs md5sum | sort -k1,1 | uniq -Dw32 \

Edit: I updated repo with the fix.

2 Likes

Debian 12, Hestiacp 1.8.1. I used this site for the test https://emkei.cz/. The email spoofing keeps coming. Can someone help me ?

2024-01-23 18:30:06 1rSJf3-000S2o-2H <= [email protected] H=emkei.cz [89.187.129.23] P=esmtps X=TLS1.3:ECDHE_SECP256R1_RSA_PSS_RSAE_SHA256_CHACHA20_POLY1305:256 CV=no S=1433 [email protected]
2024-01-23 18:30:06 1rSJf3-000S2o-2H => test <[email protected] > R=localuser T=dovecot_virtual_delivery
2024-01-23 18:30:06 1rSJf3-000S2o-2H Completed