@@ -571,6 +571,63 @@ The `allow_username_mismatch` configuration is needed here because Rspamd expect
571571but ** in this setup** OpenSMTPD authenticates against simple usernames. Also make sure the dkim key file is
572572readable by members of the ` _rspamd ` group.
573573
574+ Optional: Only accept mail in certain languages
575+ -
576+ Rspamd is very configurable, and you can add your own rules. I have found the default rules are generally pretty
577+ good for a generic mail server, however I get a lot of foreign language spam. If you are certain what languages
578+ people using your server are able to understand I have found it very helpful to add a filter to mark mail read
579+ in languages I do not understand as spam I have done this with the following lua rule.
580+
581+ ``` cat << EOF >/usr/local/share/rspamd/rules/rspamd-local.lua
582+ local rspamd_logger = require ' rspamd_logger'
583+
584+ local ok_langs = {
585+ [' en' ] = true ,
586+ [' fr' ] = true ,
587+ }
588+
589+ rspamd_config .LANG_FILTER = {
590+ callback = function (task )
591+ local any_ok = false
592+ local lang_seen = false
593+ local parts = task :get_text_parts ()
594+ for i , p in ipairs (parts ) do
595+ local ln = p :get_language () or ' '
596+ local dash = ln :find (' -' )
597+ if dash then
598+ -- from zh-cn to zh
599+ ln = ln :sub (1 , dash - 1 )
600+ end
601+ lang_seen = true
602+ rspamd_logger .infox (" lang for %1 is %2" , i , ln )
603+ if ok_langs [ln ] then
604+ any_ok = true
605+ end
606+ end
607+ if any_ok then
608+ return 0.1
609+ end
610+ if not (lang_seen ) then
611+ rspamd_logger .infox (" no language seen" )
612+ return 0.1
613+ end
614+ return 1.0
615+ end ,
616+ score = 6.0 ,
617+ description = ' no ok languages' ,
618+ }
619+ EOF
620+ ```
621+
622+ You will need to edit the above added file if you understand different languages than
623+ english and french. To activate it, add a line to /usr/local/share/rspamd/rules/rspamd.lua:
624+
625+ ```
626+ dofile(local_rules .. '/rspamd-local.lua')
627+ ```
628+
629+ Enable and start redis and rspamd
630+ -
574631We're done here, Rspamd and Redis can be enabled so OpenBSD starts them at next reboot:
575632```
576633# rcctl enable redis
0 commit comments