[Rspamd-Users] Block emails with Chinese and Cyrillic characters in the subject

G.W. Haywood rspamd at jubileegroup.co.uk
Wed Aug 6 11:24:23 UTC 2025


Hi there,

On Wed, 6 Aug 2025, Andreas wrote:

> Hello everyone,
>
> I want to use Rspamd to block emails whose subject line contains Chinese or
> Cyrillic characters. The reason is ...

We know, we know. :)

> ...
> Does anyone have a tip on how to reliably implement this with Rspamd? Perhaps
> I'm doing something wrong with the regular expressions or the map configuration.

I don't actually use rspamd to do this but I do block them with a
different milter.  Most of the time the subject header is Base64
encoded, not literally written in UTF-8 characters (which in SMTP was
once upon a time forbidden) so if you try to block UTF-8 characters
that will fail because there aren't any.  A mail client typically
however recognizes these encoded headers and do the 'helpful' thing to
show you what the bonehead who wrote the software thought you'd want
to see.  I really dislike such helpful software.

Here is a typical Base64 encoded subject header from this morning's
rejections here:

Subject: =?utf-8?B?44CQ57eK5oCl44CR5LuK5YuV44GL44Gq44GE44Go5LiA55Sf5b6M5oKU44GX44G+44GZ44CC5bm05Yip?=
 	=?utf-8?B?Mjcl44Gu5qCq44CB5pei44Gr5Y+X5LuY5p6g5q6L44KK44KP44Ga44GL44CC?=

As you can see they're all ASCII characters, and unless they're
re-written by rspamd into UTF-8 UTF-8 *before* your regex tries to
match them then it won't match.  I didn't trace through all the
possible permutations to see if rspamd will do what's required, I just
did what was easy at the time.

To begin with you might try matching something like

/Subject: =?utf-8?B?44/

and refine it from there if you find it works for you.

-- 

73,
Ged.


More information about the Users mailing list