0

We have an email server running Dovecot and Postfix.

I recieve a lot of spam email containing wierd chinese/japanese or other asian characters.

We don't need these emails in our organization and we do not communicate with people using asian characters.

How can we instruct Postfix to block out all emails containing asian characters ?

We already use "body_checks" to discard email containing some regex strings... but how can we do it for asian characters ?

Server [/etc/postfix] # cat body_checks
/free mortgage quote/     DISCARD
/repair your credit/      DISCARD
/From:.*<>/         DISCARD
Server [/etc/postfix] # cat main.cf |grep body
body_checks = pcre:/etc/postfix/body_checks
Server [/etc/postfix] #
1
  • my answer is not be related to the question but have you considered using any antispam solution?
    – FatRabbit
    Jun 1, 2022 at 6:53

2 Answers 2

2

Try adding these lines:

/^Subject:.*=\?(?:GB2312|big5)\?/   DISCARD
/^Content-Type:.*\bcharset="?(?:GB2312|big5)\b/   DISCARD
/(?:[a-z0-9]?[\200-\377]){8,}/   DISCARD

They will discard email containing the most common chinese encodings, such as big5 and GB2312

1
  • /^Content-Type:.*\bcharset="?(?:GB2312|big5)\b/ DISCARD This one doesn't work... Also, I have discovered that some emails are encoded in Base64. This, effectively, bypasses the checks. How can I check for base64 encoded strings of asian characters ?
    – Adam
    Jul 28, 2022 at 17:15
0

I have tried - with no result. I always try to solve my problems before posting in the forums. Usually, the forums are the last place to try to ask help, and after all other attempts failed.

The problem is simple: I want to filter asian characters.

Here is my header_checks file:

/free mortgage quote/     DISCARD
/repair your credit/      DISCARD

Here is my body_checks file: https://pastebin.com/mF0VLCzY

The filtering works great if I test any asian character from the list in the body_checks file.

The problem is that I receive emails which ENCODE with Base64 (the Email client displays the asian character but the Message Source is Encoded in Base64). For example: 連 in Base64 is "6YCj" And my message source is full of Base64 encoded text.

I have also tried these:

/^Subject:.*=\?(?:GB2312|big5)\?/   DISCARD
/^Content-Type:.*\bcharset="?(?:GB2312|big5)\b/   DISCARD
/(?:[a-z0-9]?[\200-\377]){8,}/   DISCARD

It gives me the following problem:

postmap: warning: header_checks, line 5: unbalanced '"' in '/^Content-Type:.*\bcharset="?(?:GB2312|big5)\b/   DISCARD' -- ignoring this line

Also, if I leave these in header_checks, it still doesn't filter the base64-encoded characters...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.