postfix는 "mail from"과 "receive to"를 기준으로 들어오는 메일을 필터링합니다.

postfix는 "mail from"과 "receive to"를 기준으로 들어오는 메일을 필터링합니다.

여러 기준에 따라 postfix 서버로 전송된 이메일을 거부하고 싶습니다. 특히 러시아 이메일 주소(또는 키릴 문자가 포함되어 있지만 더 어려울 것 같습니다)에서 두 명의 특정 수신자에게 전송되는 이메일을 차단하고 싶습니다. 다른 사람에게 기록됩니다.)

나는 이것이 간단해야 한다고 생각합니다. 특히 "mail from"과 "rcpt to" 주소가 모두 smtp 협상 시작 부분에 제공되기 때문입니다. 하지만 postfix를 사용하여 이 작업을 수행하는 방법을 찾을 수 없으며 추가 패키지(milter?)가 필요한지 확실하지 않습니다.

답변1

하나 추가제한 수준. 예를 들어:

/etc/postfix/main.cf:
smtpd_recipient_restrictions =
    check_recipient_access hash:/etc/postfix/recipient_access

smtpd_restriction_classes = no_russians
no_russians = check_sender_access pcre:/etc/postfix/no_russians


/etc/postfix/recipient_access:
[email protected]     no_russians
[email protected]     no_russians

/etc/postfix/no_russians:
/\.ru$/ REJECT

답변2

기본적으로 복사/붙여넣기https://sources.debian.org/src/postfix/3.6.4-1/examples/smtpd-policy/greylist.pl/#L257그리고 진행하면서 조정하기 위해 간단한 스크립트 no_ru.plcheck_policy_service구현할 수 있는 간단한 Perl 스크립트가 있습니다. 바라보다http://www.postfix.org/SMTPD_POLICY_README.html연결하는 방법을 알아보세요.

테스트되지 않은 YMMV et al. 다음 use과 같은 일부 기능이 필요할 수도 있고 초기화할 수도 있습니다 syslog. 먼저 명령줄에서 시도해 보세요.

# Unbuffer standard output.
#
select((select(STDOUT), $| = 1)[0]);

#
# Receive a bunch of attributes, evaluate the policy, send the result.
#
%attr = ();
$ru_sender = $ru_rcpt = 0;
while (<STDIN>) {
  if (/^\s*sender=.*\.ru\n/i) {
     $ru_sender = 1;
  } elsif (/^\s*recipient=.*\.ru$/i) {
     $ru_rcpt = 1;
  } elsif ($_ eq "\n") {
    if ($verbose) {
      syslog $syslog_priority, "ru_sender %i, ru_rcpt %i", $ru_sender, $ru_rcpt;
    }
    $action = ($ru_sender && $ru_rcpt) ? "reject" : "dunno";
    syslog $syslog_priority, "Action: %s", $action if $verbose;
    print STDOUT "action=$action\n\n";
    %attr = ();
  } else {
    chop;
    syslog $syslog_priority, "warning: ignoring garbage: %.100s", $_;
  }
}

답변3

보기 smtpd_recipient_restrictionssmtpd_sender_restrictions명령. 이를 사용하면 필요한 필터가 포함된 해시 맵을 구성할 수 있습니다.

smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender_access

/etc/postfix/sender_access:
.ru                       REJECT
[email protected]        REJECT

당신은 또한 볼 수 있습니다http://www.postfix.org/ADDRESS_VERIFICATION_README.html그리고http://www.postfix.org/SMTPD_ACCESS_README.html

관련 정보