透過 sendmail/postdrop 限製本地郵件的 Postfix 傳送選項

透過 sendmail/postdrop 限製本地郵件的 Postfix 傳送選項

我有一個運行 Postfix 的臨時伺服器,我只想將其設定為將郵件傳遞到 example.org。如果我們正在測試發送電子郵件的功能,我們希望能夠知道我們不會意外地將任何測試訊息發送給測試域之外的任何人。

所有郵件都從該伺服器傳送到智慧型主機進行投遞。

我已經設定了

relay_domains = example.org
smtpd_recipient_restrictions = reject_unauth_destination

這意味著伺服器僅透過 SMTP 中繼 example.org。但是,在伺服器上使用 mail(1),它將發送到所有位址。我怎樣才能將其限制為僅relay_domains?

答案1

正是受人尊敬的 Postfix 作者 Wietse Venema給了我們答案:

也許使用傳輸表,利用其特殊語法:

/etc/postfix/main.cf
    transport_maps = hash:/etc/postfix/transport

/etc/postfix/transport:
    example.org :
    *      error:we do not deliver this domain

對於 example.org 以外的網域,上述內容將拒絕 SMTP 郵件並退回本地提交。

相關內容