Hi, I've created a script which fetches mails from a special IMAP mailbox, where I forward spam and ham to, and feeds them to sa-learn as spam or ham. If anyone is interested to try out you can get all the details in the github repository: https://github.com/magenbrot/sa_learn_from_imap Here's a more detailed description: First up you'll need an IMAP mailbox where you and your customers redirect SPAM and HAM to. I've a mailbox called email@example.com. Since I use postfix (I don't know what other MTAs do), I can use a + in my recipient address (see recipient_delimiter documentation of Postfix). So I'm forwarding all spam to firstname.lastname@example.org and all ham to email@example.com. Furthermore I have a sieve-script running on my server, which will move the incoming mails by the recipient to the correct folder. Now about training the SpamAssassin: The script has 3 required, positional arguments. The IMAP-host, -user and the -password. By default it assumes that your SPAM mails are sorted in a folder called 'spam' and your HAM mails are filed in 'ham'. This can be changed with the parameters --spam-folder and --ham-folder. It needs a working directory, this is /tmp/sa-learn by default and can be changed with the --directory parameter. Finally you can specify the sa-learn script it should use with --sa-learn. This defaults to /usr/bin/sa-learn. Please call the script with the user you're running SpamAssassin with. Example (run with python3, either directly or in the venv from above): Code: ./sa_learn_from_imap.py mail.mymails.org 'firstname.lastname@example.org' 'password123$' A cronjob could look like this, put this in /etc/cron.d/sa-learn-ham-spam: Code: #MAILTO="email@example.com" MAILTO="" # run with bash, as sh doesn't support 'source' SHELL=/bin/bash 15 * * * * root source /opt/sa_learn_from_imap/env/python3/bin/activate && \\ /opt/sa_learn_from_imap/sa_learn_from_imap.py mail.mymails.org 'firstname.lastname@example.org' 'password123$'