LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-30-2022, 05:20 AM   #1
AsgAnquietas
Member
 
Registered: Oct 2008
Posts: 82

Rep: Reputation: 1
Question Postfix block email with asian characters


Hello,

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 ?

Code:
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] #
 
Old 05-30-2022, 09:27 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,747

Rep: Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982
Quote:
Originally Posted by AsgAnquietas View Post
Hello,
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 ?

Code:
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] #
Put a content check in place to scan for the desired character sets, either in the header/subject/content-type. And which asian characters? More than one set, since that encompasses Japanese, Chinese, and Korean. You've already got rules in place, so adding one more shouldn't be a problem, especially since you've been working with postfix for a while now.

Last edited by TB0ne; 05-30-2022 at 09:30 AM.
 
Old 07-28-2022, 12:16 PM   #3
AsgAnquietas
Member
 
Registered: Oct 2008
Posts: 82

Original Poster
Rep: Reputation: 1
ok, how can I do this ?

This seems so nice in theory, but what must I physically do ? :-))
 
Old 07-28-2022, 12:27 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,747

Rep: Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982
Quote:
Originally Posted by AsgAnquietas View Post
ok, how can I do this ? This seems so nice in theory, but what must I physically do ? :-))
Did you try reading the Postfix documentation on content checking???
https://www.postfix.org/CONTENT_INSPECTION_README.html

May want to check your thread on the Ubuntu forums (which came up from a Google search for your question), where you were provided a filter.
https://askubuntu.com/questions/1411...ian-characters
 
Old 07-28-2022, 12:27 PM   #5
AsgAnquietas
Member
 
Registered: Oct 2008
Posts: 82

Original Poster
Rep: Reputation: 1
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 ?
 
Old 07-28-2022, 12:53 PM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,747

Rep: Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982
Quote:
Originally Posted by AsgAnquietas View Post
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 ?
...which is the same thing you asked in your other thread, and don't acknowledge. Again, read the postfix docs..you can use body_check for such things, or use amavis/spamassassin.
 
Old 07-29-2022, 07:59 AM   #7
AsgAnquietas
Member
 
Registered: Oct 2008
Posts: 82

Original Poster
Rep: Reputation: 1
In esence, I'm back to square one...

1. The Postfix documentation is so hard to understand, I need a practical solution - I thought there is a quick fix since I believe I'm not the only one experiencing problems with asian characters... OK, i'll read the docs... I was hoping for a quick fix...
2. If you look closely to my reply on Ubuntu Forums, I have specifically written the fact that a specific line from the given solution does not work...
3. Regarding decoding of base64, I didn't find anything...
 
Old 07-29-2022, 08:53 AM   #8
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,747

Rep: Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982
Quote:
Originally Posted by AsgAnquietas View Post
In esence, I'm back to square one...

1. The Postfix documentation is so hard to understand, I need a practical solution - I thought there is a quick fix since I believe I'm not the only one experiencing problems with asian characters... OK, i'll read the docs... I was hoping for a quick fix...
2. If you look closely to my reply on Ubuntu Forums, I have specifically written the fact that a specific line from the given solution does not work...
3. Regarding decoding of base64, I didn't find anything...
So:
  1. You're essentially asking others to read the docs and only pull out the pieces you need, rather than you doing it. If you use the search terms given you to, you'll find examples; start there.
  2. If you look closely, saying "does not work" isn't much of a problem description. Further, if you put MORE character sets in, as opposed to just the ones in the example, then it'll filter more, wouldn't it??
  3. You were handed a search term, and a link to the docs specifically related to content inspection. You were given names of programs that DO THIS.
 
Old 07-29-2022, 12:29 PM   #9
AsgAnquietas
Member
 
Registered: Oct 2008
Posts: 82

Original Poster
Rep: Reputation: 1
With all due respect, it seems that the Forum is not much help for "read read read".
I came to the forums seeking a proven solution, in case anyone already dealt with this issue.
I do not ask others to read for me ! This is called misjudging. I learned to read when I was 4 :-)
The ideea was to obtain a quick fix IF someone else already encountered the problem - I assume that is also the role of a Forum - to ask quick help, if available :-)
I assume anyone can read :-)
OK, back to reading manuals. Thank you.
 
Old 07-29-2022, 12:41 PM   #10
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,747

Rep: Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982
Quote:
Originally Posted by AsgAnquietas View Post
With all due respect, it seems that the Forum is not much help for "read read read". I came to the forums seeking a proven solution, in case anyone already dealt with this issue. I do not ask others to read for me ! This is called misjudging. I learned to read when I was 4 :-) The ideea was to obtain a quick fix IF someone else already encountered the problem - I assume that is also the role of a Forum - to ask quick help, if available :-) I assume anyone can read :-)
OK, back to reading manuals. Thank you.
And with all due respect, the forum is here if you're needing HELP...not wanting to read the instructions/claim they're 'hard to understand', etc., and wanting someone else to read them for you doesn't fall within that realm.

You were given a filter on your other thread, in another forum...all you've said is it "doesn't work". Nothing about WHAT isn't working/how/why, or what you've actually tried to MAKE IT WORK. Again, if it's not filtering everything, then expand the character sets. This is all information you can look up for yourself, and (since you don't actually give us details about what's not working), that's all we can tell you isn't it??? Should we guess as to what it's not doing??

You asked about content filtering; again, that's covered in the postfix docs...can you show us what YOU have done to try to accomplish this?? Have you looked at the things you were given/had looked up for you regarding amavis/spamassassin, to do exactly what you're after???

Forums are here to help people help themselves. This is like asking someone to help you paint your house, only for you to sit in a chair and watch them...that's not help...that's having it done for you.

Last edited by TB0ne; 07-29-2022 at 12:45 PM.
 
Old 07-29-2022, 12:53 PM   #11
AsgAnquietas
Member
 
Registered: Oct 2008
Posts: 82

Original Poster
Rep: Reputation: 1
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:
Code:
/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:
Code:
/^Subject:.*=\?(?:GB2312|big5)\?/   DISCARD
/^Content-Type:.*\bcharset="?(?:GB2312|big5)\b/   DISCARD
/(?:[a-z0-9]?[\200-\377]){8,}/   DISCARD
It gives me the following problem:
Code:
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...
 
Old 07-29-2022, 01:09 PM   #12
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,747

Rep: Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982
Quote:
Originally Posted by AsgAnquietas View Post
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.
...and if you don't actually show us what you've done/tried, how exactly do you expect us to know???
Quote:
The problem is simple: I want to filter asian characters. Here is my header_checks file:
Code:
/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.
Great...so the asian character filtering DOES work, which isn't what you indicated previously.
Quote:
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:
Code:
/^Subject:.*=\?(?:GB2312|big5)\?/   DISCARD
/^Content-Type:.*\bcharset="?(?:GB2312|big5)\b/   DISCARD
/(?:[a-z0-9]?[\200-\377]){8,}/   DISCARD
It gives me the following problem:
Code:
postmap: warning: header_checks, line 5: unbalanced '"' in '/^Content-Type:.*\bcharset="?(?:GB2312|big5)\b/   DISCARD' -- ignoring this line
...meaning that you have a syntax/mismatch in that file...meaning you need to go fix it. It's not only telling you what the problem is, but what line it's on. Hard to be more clear than that...have you actually LOOKED at the file? The error is very clear in what you posted.
Quote:
Also, if I leave these in header_checks, it still doesn't filter the base64-encoded characters...
Right, which takes us back to "use one of the tools that were given to you before". AGAIN: amavis/spamassassin do these things, and you've been using spamassassin for a while now. Implement the content filter there, or AGAIN, read the documentation on content inspection.
 
Old 08-11-2022, 09:27 AM   #13
AsgAnquietas
Member
 
Registered: Oct 2008
Posts: 82

Original Poster
Rep: Reputation: 1
I've corrected that syntax problem, however, it still doesn't filters asian chars.
I will try with SpamAssassin.
 
Old 08-11-2022, 09:39 AM   #14
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,747

Rep: Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982Reputation: 7982
Quote:
Originally Posted by AsgAnquietas View Post
I've corrected that syntax problem, however, it still doesn't filters asian chars. I will try with SpamAssassin.
Great how you followed up after having it pointed out to you. Also, you said before it *DID* filter asian characters (post #11, where you said it did), and that you were needed ADDITIONAL filtering, which postfix doesn't do.

Again: you have been using spamassassin for years, which does attachment filtering/inspection...you were given a link to another program as well.
 
Old 08-11-2022, 09:41 AM   #15
AsgAnquietas
Member
 
Registered: Oct 2008
Posts: 82

Original Poster
Rep: Reputation: 1
Thank you for pointing it out.
I mean it filters asian chars if the email is plain email.
If the content is Base64 encoded and the email client decodes the Base64 content, then the filtering has no effect.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
East Asian Characters Zepx Linux - Newbie 2 08-04-2010 11:00 PM
Renaming files with asian characters /dev/stderr Programming 1 07-19-2010 06:09 AM
Files using Asian characters can't be read Mega Man X Ubuntu 0 04-29-2007 04:20 PM
I need some Asian Character Font support SuseBoy Linux - General 7 10-23-2003 09:32 AM
Can Slackware9.1 support Asian Language ? preswang Linux - Software 0 10-15-2003 07:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration