Table of Contents

Ubuntu - SpamAssassin - Only accept email in specified languages

Use the TextCat plugin.

In /etc/spamassassin/local.pre add:

loadplugin Mail::SpamAssassin::Plugin::TextCat

In /etc/spamassassin/local.cf add:

ok_languages en af

Where “en af” is a list of codes for languages you wish to accept. The full list is in the TextCat documentation.

If the guessed language is not okay, “UNWANTED_LANGUAGE_BODY” is triggered.

The results are added to a “X-Language” name-value pair in the message metadata data structure. This may be useful as Bayes tokens and can also be used in rules for scoring. The results can also be added to marked-up messages using “add_header”, with the _LANGUAGES_ tag. See Mail::SpamAssassin::Conf for details.

NOTE: The language cannot always be recognized with sufficient confidence. In that case, no action is taken.

IMPORTANT: It is very important that the loadplugin line be added to a .pre file not a .cf file so it is loaded before the rules files are loaded, otherwise those rules will not get enabled.

You may also want to increase the score from the default of 2.8:

score UNWANTED_LANGUAGE_BODY 5

Languages Supported by TextCat

afAfrikaans
amAmharic
arArabic
beByelorussian
bgBulgarian
bsBosnian
caCatalan
csCzech
cyWelsh
daDanish
deGerman
elGreek
enEnglish
eoEsperanto
esSpanish
etEstonian
euBasque
faPersian
fiFinnish
frFrench
fyFrisian
gaIrish Gaelic
gdScottish Gaelic
heHebrew
hiHindi
hrCroatian
huHungarian
hyArmenian
idIndonesian
isIcelandic
itItalian
jaJapanese
kaGeorgian
koKorean
laLatin
ltLithuanian
lvLatvian
mrMarathi
msMalay
neNepali
nlDutch
noNorwegian
plPolish
ptPortuguese
quQuechua
rmRhaeto-Romance
roRomanian
ruRussian
saSanskrit
sc Scots
skSlovak
slSlovenian
sqAlbanian
srSerbian
svSwedish
swSwahili
taTamil
thThai
tlTagalog
trTurkish
ukUkrainian
viVietnamese
yiYiddish
zhChinese (both Traditional and Simplified)
zhg5 - Chinese (Traditional only)
zh2312 - Chinese (Simplified only)

References

http://manpages.ubuntu.com/manpages/zesty/man3/Mail::SpamAssassin::Plugin::TextCat.3pm.html