I have MailScanner too, I use it with postfix and dovecot and all my user accounts are virtual (stored in MySQL)
I presume your current configuration is working, right ? What you need is a sieve modul for dovecot
Mail filtering is done by dovecot's deliver + sieve, that's why you have to set up your postfix to use dovecot's deliver for mail delivery and set up your dovecot to use sieve plugin.
Here are the most important parts of my configuration:
Postfix
master.cf
# ...
dovecot unix - n n - - pipe
flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${recipient}
# ...
main.cf
# ...
virtual_transport=dovecot
dovecot_destination_recipient_limit=1
# ...
MailScanner
MailScanner.conf
# ...
%org-name% = MYORG
Required SpamAssassin Score = 5
High SpamAssassin Score = 10
Spam Score = yes
Spam Actions = deliver header "X-MYORG-Spam-Flag: Yes"
High Scoring Spam Actions = delete
# ...
Dovecot
# ...
protocol lda {
mail_plugins = cmusieve
global_script_path = /var/spool/vmail/globalsieverc
log_path = /var/log/dovecot/deliver.log
info_log_path = /var/log/dovecot/deliver.log
# ...
}
auth default {
socket listen {
master {
path = /var/run/dovecot/auth-master
mode = 0660
user = vmail
group = vmail
}
# ...
}
# ...
/var/spool/vmail/globalsieverc
require ["fileinto"];
# ...
#
# Move SPAM to Junk
#
if anyof (
header :contains ["X-MYORG-MailScanner-SpamScore"] "sssss",
header :contains ["X-MYORG-Spam-Flag"] "Yes"
) {
fileinto "Junk"; stop;
}
Don't forget to doublecheck right permissions to all config files and directories.