在 Unix/Linux 環境下運行 Sendmail 時,若寄信出現:
----- Transcript of session follows -----
554 5.0.0 MX list for example.com. points back to example.com.
554 5.3.5 ... Local configuration error
即表示 Sendmail 認定自己是收件域名的最終 MX,卻又無法本地投遞,導致郵件迴路。根因通常是 /etc/mail/sendmail.cf 中 Cw (本地主機名稱清單) 缺少完整域名。
/etc/mail/sendmail.cf(或 sendmail.mc 重建)Cwlocalhost 行Cwexample.com(您的實際郵件域名)| 作業系統 | 指令 |
|---|---|
| Solaris 8/9/10 | |
| Linux (SysVinit) | |
| Linux (systemd) | |
| FreeBSD |
Cw 定義 Sendmail 認為「屬於本機」的主機名稱集合mail.example.com → 解析 IP → 比對本機介面 IPCw 無 example.com,Sendmail 認為「我是 MX 卻不認領此域」→ 拋 554 拒收Cwexample.com 後,Sendmail 承認本地投遞責任,郵件進入 local mailer 投遞至 /var/mail 或 procmail# /etc/mail/sendmail.mc
define(`confDOMAIN_NAME', `example.com')dnl
FEATURE(`use_cw_file')dnl
# 實際主機名單寫在 /etc/mail/local-host-names
example.com
mail.example.com
localhost
修改 .mc 後:
cd /etc/mail
make # 產生 sendmail.cf
systemctl restart sendmail
優點:集中管理、版本控制、避免手改 .cf 格式錯誤。
host example.com 解析是否指向本機 IP?/etc/hosts 是否有 127.0.0.1 example.com 干擾?mail.example.com?/var/log/maillog 是否有其他 5xx 錯誤。