該伺服器同時安裝了 sendmail 和 postfix。 Sendmail 已運作但無法正常運作。我停止了 sendmail 服務並啟動了 postfix。透過檢查連接埠 25 上偵聽的內容的輸出,確認只有 postfix 正在運作。
lsof -i :25
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
master 119640 root 12u IPv4 28103863 0t0 TCP localhost:smtp (LISTEN)
master 119640 root 13u IPv6 28103864 0t0 TCP localhost:smtp (LISTEN)
然後我測試發送郵件:
echo "My message" | mail -s testing [email protected]
它不會到達 root 的收件匣。因此,我查看了 /var/log/maillog 中的日誌,發現 sendmail 仍在使用中:
Feb 26 16:18:13 server sendmail[1582]: w1QLIC8N001582: [email protected], ctladdr=root (0/0), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30233, relay=exchangeserver.domain. [x.x.x.x], dsn=2.0.0, stat=Sent (<201802262118.w1QLIC8N001582@[email protected]> Queued mail for delivery)
這怎麼可能?
答案1
程式mail
運行sendmail
以傳送郵件(在用戶端模式下,該過程中沒有開啟偵聽連接埠)。閱讀手冊頁獲取詳細資訊。您可以透過設定變數來更改 MDA sendmail
:
傳送郵件
若要使用備用郵件傳送系統,請將此選項設定為要使用的程式的完整路徑名稱。這應該小心使用。
$ sendmail=/usr/bin/someothersendmail mail [email protected]
Subject: asdf
... and so on
但由於 mail 期望 MDA 能夠識別 sendmail 的選項,因此我並不真正了解它的用途。
另一種可能性是使用外部 SMTP 伺服器代替sendmail
。
$ echo "This is the message body and contains the message" | mailx -v \
> -r "[email protected]" \
> -s "This is the subject" \
> -S smtp="mail.example.com:587" \
> -S smtp-use-starttls \
> -S smtp-auth=login \
> -S smtp-auth-user="[email protected]" \
> -S smtp-auth-password="abc123" \
> -S ssl-verify=ignore \
> [email protected]
答案2
crontab
此日誌行不是來自TCP連接埠 25 上的任何偵聽。或者它是一些非標準的 root 擁有的後台進程。