
我想要一個後綴,允許郵件中繼到中繼主機
a) 允許寄件者域
以及以下之一:
b) 發送者已通過驗證 c) 用戶端有 IP 白名單條目
到目前為止我目前的方法是:
relayhost = [RELAYHOST]:25
smtpd_reject_unlisted_sender = yes
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/restricted_senders
smtpd_recipient_restrictions =
check_client_access cidr:/etc/postfix/ip_whitelist,
permit_sasl_authenticated,
reject_unauth_destination
受限制的寄件者包含
example.com OK
和 ip_whitelist 包含
192.168.1.3 OK
雖然可以從經過驗證的用戶端或 IP 白名單用戶端發送郵件,但寄件者網域限制不起作用。似乎只要身份驗證或 client_access 匹配,就不再檢查寄件者限制。
答案1
為什麼這不起作用?
預設設定是允許一切。
指定限制列表,以逗號和/或空格分隔。以空格開始下一行來繼續長行。限制按指定的順序套用;第一個匹配的限制獲勝。
和
check_sender_access type:table
搜尋指定的訪問(5)資料庫中尋找
MAIL FROM
地址、網域、父域或localpart@
,並執行對應的操作。
因此,您的配置首先允許example.com
from /etc/postfix/restricted_senders
,然後允許其他所有內容。這smtpd_reject_unlisted_sender
並沒有改變這一點,因為:
當 1) 與地址不符時,地址被視為“未知”虛擬(5)別名或規範(5)映射,以及 2) 該位址對其位址類別無效。有關基於類別的位址驗證的定義,請參閱ADDRESS_CLASS_README。
域,例如,example.org
不在當地的,虛擬別名,虛擬信箱也不中繼域類,因此它屬於預設域類。該類別沒有目的地,也沒有有效的收件人表。顯然,任何不屬於其他網域類別的位址對於該位址類別都是有效的。這是合乎邏輯的,因為本機系統不知道遠端系統上哪些位址可用。
smtpd_sender_restrictions
對此就足夠了
忘記smtpd_reject_unlisted_sender
因為這可以smtpd_sender_restrictions
單獨使用來完成。
最簡單的配置是:
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/restricted_senders, reject
另一個選擇是使用
regex:
表格:smtpd_sender_restrictions = check_sender_access regex:/etc/postfix/restricted_senders
這使得可以使用常用表達:
/example\.com$/ OK // 550 You are not allowed to use this sender address.
您可以使用以下命令測試查找結果
postmap -q
:$ /usr/sbin/postmap -q [email protected] regexp:/etc/postfix/restricted_senders 550 You are not allowed to use this sender address. $ /usr/sbin/postmap -q [email protected] regexp:/etc/postfix/restricted_senders OK