2022. 8. 10. 18:56 WorkHolic/스크랩
Postfix + header_checks in MySQL
728x90
반응형
Postfix + header_checks in MySQL
Now create the header_checks table with the following command:
CREATE TABLE `header_checks` (
`hc_id` int(11) NOT NULL AUTO_INCREMENT,
`rule` varchar(255) NOT NULL,
`action` varchar(255) NOT NULL,
PRIMARY KEY ( `hc_id`),
KEY `rule` (`rule`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
Postfix preparation
I believe that you must already have Postfix installed on your server, there are already several articles dealing with its installation.We will now create the configuration file for communicating with MySQL:
# vi /etc/postfix/header_checks.cf
Put this content inside the file we are editing:
user = YOUR_BANK_USER_postfix
password = YOUR_BANK_PASSWORD_postfix
hosts = IP_or_YOUR_Server_NAME
dbname = DATABASE_NAME_postfix
query = SELECT action FROM header_checks WHERE '%s' REGEXP rule LIMIT 0.1
Next step is to edit the configuration in the /etc/postfix/main.cf file , if you don't already have the line below, add it:
password = YOUR_BANK_PASSWORD_postfix
hosts = IP_or_YOUR_Server_NAME
dbname = DATABASE_NAME_postfix
query = SELECT action FROM header_checks WHERE '%s' REGEXP rule LIMIT 0.1
header_checks = mysql:/etc/postfix/header_checks.cf
With these steps completed, we just have to restart postfix and populate the header_checks table in MySQL, which I will show the correct syntax below.# /etc/init.d/postfix restart
Creating check rules in MySQL
Here we don't have many secrets, what gave me more work was finding the correct syntax to write the rule, but I'll save you this hard work and pass the correct syntax the way I'm using it on my servers.Access MYSQL:
# mysql -u root -p
use postfix;
INSERT INTO header_checks (`hc_id`, `rule`, `action`) VALUES (NULL, '^From:(.*)domain.com.br', 'DISCARD #SPAM Domain Detected');
Note that the syntax for REGEXP used by header_checks follows the following pattern:
^From:(.*)dominio.com.br
I particularly use this rule to block domains that usually send SPAMs, but we can use it, for example, to block messages with certain subjects, in this case the rule would look like this:
^Subject:(.*)PROPAGANDA
Well folks, that's it...
I hope the subject has been addressed in a clear and objective way.
Hugs.
Measure
Measure
#postfix #header_checks #mysql
728x90
SMALL
'WorkHolic > 스크랩' 카테고리의 다른 글
PHP 5.3 을 PHP 5.2로 다운그레이드 하는 방법 (0) | 2023.12.19 |
---|---|
윈도 서버 2022 네트워크 티밍 방법 (0) | 2023.07.18 |
(스크랩) Windows용 최고의 스크린샷 도구 (0) | 2022.03.25 |
(스크랩) HP iLO(2~4)비밀번호 재설정 방법 (0) | 2022.01.25 |
(스크랩) SpamAssassin rules Automatic rule generation (0) | 2022.01.10 |