Sendmail:本地和非本地地址的統稱

Sendmail:本地和非本地地址的統稱

我需要為測試環境設定一個郵件伺服器配置,該配置將接受所有郵件(即所有使用者和所有網域,甚至是非本機郵件)並將其放入單一本機綜合信箱。

我擁有的是帶有 Sendmail (8.14) 的 SLES 11,我嘗試將 /etc/mail/virtusertable 修改為如下所示

@ catchall

或喜歡

@* catchall

但無濟於事 - 目的地郵件地址(例如[電子郵件受保護]) 不被重寫為包羅萬象@,因此將嘗試傳遞到適當的 MX:

# sendmail -bt
ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>
> 3,0 [email protected]
canonify           input: santa @ northpole . org
Canonify2          input: santa < @ northpole . org >
Canonify2        returns: santa < @ northpole . org . >
canonify         returns: santa < @ northpole . org . >
parse              input: santa < @ northpole . org . >
Parse0             input: santa < @ northpole . org . >
Parse0           returns: santa < @ northpole . org . >
ParseLocal         input: santa < @ northpole . org . >
ParseLocal       returns: santa < @ northpole . org . >
Parse1             input: santa < @ northpole . org . >
MailerToTriple     input: < > santa < @ northpole . org . >
MailerToTriple   returns: santa < @ northpole . org . >
Parse1           returns: $# esmtp $@ northpole . org . $: santa < @ northpole . org . >
parse            returns: $# esmtp $@ northpole . org . $: santa < @ northpole . org . >

查找表的來源域部分似乎不支援通配符。

我該如何使用 Sendmail 來實現這一點?

編輯:按照安傑伊的評論我嘗試過 mailertable 條目

. local:catch-all-outgoing

.. local:catch-all-outgoing

sendmail -bv並在兩種情況下收到相同的輸出:

# sendmail -d60.5 -bv [email protected]
map_lookup(dequote, root, %0=root) => NOT FOUND (0)
map_lookup(host, example.net, %0=example.net) => example.net. (0)
[email protected]... deliverable: mailer esmtp, host example.net., user [email protected]

是的,root,似乎sendmail無法以非 root 身分運行

編輯:事實證明,在巨集檔案中尚未啟用 mailertable 功能,因此 sendmail.cf 不包含使其工作的適當重寫規則。

答案1

您在這裡遇到的情況:/etc/mail/virtusertable我相信僅限於入站電子郵件,而不是出站電子郵件。

您可以使用 mailertable 或 SMART_HOST 中的預設路由將所有非本地郵件傳遞到一個本地郵箱/別名。

mailertable entry:
. local:catch-all-outgoing

aliases:
catch-all-outgoing: some-local-account

任何不以點開頭的 LHS 條目都與指示的完整主機名稱相符。以點開頭的 LHS 條目匹配以該網域結尾的任何內容(包括前導點)——也就是說,它們可以被認為具有用於非空字元序列的前導「.+」正規表示式模式。

RHS 應始終是「郵件程式:主機」對。 mailer是郵件程式的設定名稱(即sendmail.cf檔案中的M行)。 「主機」將是傳遞給該郵件程式的主機名稱。

(參考:發送郵件自述文件,「使用郵件表」部分)

所以像這樣:

. local:catch-all-outgoing(只是一個點阿傑的評論/etc/mail/mailertable 中的 ) 應導致任何 domain.tld 重定向到 sendmail.cf 中定義的本機郵件程式設定。使用別名捕獲主機名catch-all-outgoing並使其成為本機電子郵件地址。

為了讓 mailertable 運作,需要在設定中啟用它。添加

FEATURE(`mailertable',`hash -o /etc/mail/mailertable.db')dnl

產生配置的 m4 巨集檔案應該可以解決這個問題。

也來自 sendmail 站點幫助文件:

郵遞表:

包含一個“郵件程式表”,可用於覆寫特定網域的路由(不屬於{w}類,即本機主機名稱)。 FEATURE 的參數可能是關鍵定義。如果未指定,則使用的定義為:

散列 /etc/mail/mailertable

此資料庫中的按鍵是完全限定的網域名稱或前面有點的部分網域 - 例如,「vangogh.CS.Berkeley.EDU」或「.CS.Berkeley.EDU」。作為後者的特例,“.”匹配任何未被其他鍵覆蓋的域。值的格式必須為:mailer:domain

其中「mailer」是內部郵件程式名稱,「domain」是發送郵件的位置。這些映射不會反映到訊息標頭中。作為一種特殊情況,形式:local:user 將使用本地郵件程式轉送給指定的用戶,

答案2

Sendmail:本地和非本地地址的統稱

您可以SMART_HOST為非本機網域和MAIl_HUB本機電子郵件網域進行定義。

發送郵件.mc:

define(`SMART_HOST',`local:some_existing_user')dnl
define(`MAIL_HUB',`local:some_existing_user')dnl
dnl optional part to list local users/mailboxes excluded from the redirect
dnl in /etc/mail/direct-users file (one user per line)
LOCAL_CONFIG
FL/etc/mail/direct-users
divert(0)

聚苯乙烯

用於echo '$=w' | sendmail -bt取得本機電子郵件網域的清單。預設情況下,Sendmail 會神奇地自動填入它。

mailertable 可用於從重新導向中排除某些外部網域

example.net %0

相關內容