postfix 上的篩選過濾器有問題嗎?

postfix 上的篩選過濾器有問題嗎?

我想知道是否有人可以解釋我遇到的問題,目前我有一個簡單的 postfix 伺服器,前面有一個 PMG 網關。因為 PMG 網關有垃圾郵件過濾器,所以我需要將垃圾郵件重新導向到使用者的垃圾郵件資料夾。我已經完成了這個 zimbra,但在 postfix 上我認為我錯過了一些東西。這些都是我採取的步驟

  1. 安裝套件並修改,將其添加到 main.cf 的底部
sudo apt-get install dovecot-sieve dovecot-managesieved



mailbox_command=/usr/lib/dovecot/deliver
  1. 然後編輯

    /etc/dovecot/conf.d/90-sieve.conf
    

並添加此行來配置預設位置

sieve_default = /etc/dovecot/default.sieve

然後讓 dovecot 用戶讀取該文件

chgrp dovecot /etc/dovecot/conf.d/90-sieve.conf
  1. 進入lda插件並取消註釋

    /etc/dovecot/conf.d/15-lda.conf
    mail_plugins = sieve
    
  2. 建立檔案 sieve 並編譯它

         root@mail:/etc/dovecot# cat /etc/dovecot/default.sieve
      require "fileinto";
      #Filter email based on a subject
      if header :contains "X-Spam-Flag" "YES" {
      fileinto "Junk";
     }

然後

cd /etc/dovecot

sievec default.sieve

並給予 dovecot 權限

chgrp dovecot /etc/dovecot/default.svbin
  1. 重啟 postfix 和 dovecot

我從以下地址發送一封測試垃圾郵件[電子郵件受保護]

並將 xspam 標誌標記為 ​​yes,但它繼續進入收件匣而不是垃圾資料夾

我檢查了協議

root@mail:/etc/dovecot# doveconf | grep protocols
protocols = " imap sieve pop3"
ssl_protocols = !SSLv2 !SSLv3
Return-Path: <[email protected]>
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: from mail.mydomain.com (unknown [192.168.1.248])
    (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))
    (No client certificate requested)
    by mail.mydomain.com (Postfix) with ESMTPS id CB3162033C
    for <[email protected]>; Sun, 25 Jul 2021 10:54:03 -0500 (COT)
Received: from mail.mydomain.com (localhost.localdomain [127.0.0.1])
    by mail.mydomain.com (Proxmox) with ESMTP id 3DC215C2F3E
    for <[email protected]>; Sun, 25 Jul 2021 10:48:19 -0500 (-05)
Received-SPF: softfail (gmail.com ... _spf.google.com: Sender is not authorized by default to use '[email protected]' in 'mfrom' identity, however domain is not currently prepared for false failures (mechanism '~all' matched)) receiver=mail.mydomain.com; identity=mailfrom; envelope-from="[email protected]"; helo=emkei.cz; client-ip=101.99.94.155
Authentication-Results: mail.mydomain.com; dmarc=fail (p=none dis=none) header.from=gmail.com
Authentication-Results: mail.mydomain.com; dkim=none; dkim-atps=neutral
Received: from emkei.cz (emkei.cz [101.99.94.155])
    (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))
    (No client certificate requested)
    by mail.mydomain.com (Proxmox) with ESMTPS id 6003D5C0F66
    for <[email protected]>; Sun, 25 Jul 2021 10:48:16 -0500 (-05)
Received: by emkei.cz (Postfix, from userid 33)
    id B52D62413E; Sun, 25 Jul 2021 17:48:13 +0200 (CEST)
To: [email protected]
subject: SPAM: test
From: "test" <[email protected]>
X-Priority: 3 (Normal)
Importance: Normal
Errors-To: [email protected]
Reply-To: [email protected]
Content-Type: text/plain; charset=utf-8
Message-Id: <[email protected]>
Date: Sun, 25 Jul 2021 17:48:13 +0200 (CEST)
X-SPAM-LEVEL: Spam detection results:  6
    BAYES_50                  0.8 Bayes spam probability is 40 to 60%
    DKIM_ADSP_CUSTOM_MED    0.001 No valid author signature, adsp_override is CUSTOM_MED
    FORGED_GMAIL_RCVD           1 'From' gmail.com does not match 'Received' headers
    FREEMAIL_FROM           0.001 Sender email is commonly abused enduser mail provider (vhfgyut[at]hotmail.com) (test[at]gmail.com) (test[at]gmail.com) (test[at]gmail.com) (test[at]gmail.com) (test[at]gmail.com)
    NML_ADSP_CUSTOM_MED       0.9 ADSP custom_med hit, and not from a mailing list
    SPF_HELO_PASS          -0.001 SPF: HELO matches SPF record
    SPF_SOFTFAIL            0.665 SPF: sender does not match SPF record (softfail)
    SPOOFED_FREEMAIL        1.224 -
    SPOOF_GMAIL_MID         1.498 From Gmail but it doesn't seem to be...
X-Spam-Flag: Yes

test

答案1

檢查 Dovecot 配置sieve_default=以確認您已配置預設 sieve 腳本的預期路徑。

# doveconf | grep sieve_default
 sieve_default = /var/lib/dovecot/sieve/default.sieve

此外,篩過濾器評估不會停止所有操作。將一個項目歸檔到多個資料夾中是完全有效的。如果您希望在一個資料夾中且僅在該資料夾中包含一封郵件,請在區塊stop末尾之前新增一條命令{}

# cat /etc/dovecot/default.sieve
require "fileinto";
# filter email based on a header added by proxmox mail gateway
if header :contains "X-Spam-Flag" "YES" {
   fileinto "Junk";
   stop;
}

經過預設,到達篩子腳本的末端會執行隱性keep行動stop,這樣即使未明確說明,每個未結束的呼叫(在諸如 之類的操作中)也將被保留。

答案2

非常感謝您的回复,我必須將默認位置更改為此並完成了技巧,謝謝 ouy

##
## Settings for the Sieve interpreter
##

# Do not forget to enable the Sieve plugin in 15-lda.conf and 20-lmtp.conf
# by adding it to the respective mail_plugins= settings.

plugin {
  # The path to the user's main active script. If ManageSieve is used, this the
  # location of the symbolic link controlled by ManageSieve.
 # sieve = ~/.dovecot.sieve

  # The default Sieve script when the user has none. This is a path to a global
  # sieve script file, which gets executed ONLY if user's private Sieve script
  # doesn't exist. Be sure to pre-compile this script manually using the sievec
  # command line tool.
  # --> See sieve_before fore executing scripts before the user's personal
  #     script.
  #sieve_default = /var/lib/dovecot/sieve/default.sieve
 sieve_default = /etc/dovecot/default.sieve

相關內容