最近又碰到一起Linux下SendMail發送郵件失敗的案例,郵件發送後,郵箱收不到具體郵件, 查看日誌/var/log/maillog 發現有"DSN: User unknown"以及“dsn=5.1.1, stat=User unknown”等錯誤信息,脫敏後的具體日誌如下所示: Nov 1 0... ...
最近又碰到一起Linux下SendMail發送郵件失敗的案例,郵件發送後,郵箱收不到具體郵件, 查看日誌/var/log/maillog 發現有"DSN: User unknown"以及“dsn=5.1.1, stat=User unknown”等錯誤信息,脫敏後的具體日誌如下所示:
Nov 1 00:45:41 mylnx01 sendmail[17770]: v9VGjfnA017770: Authentication-Warning: mylnx01.xxxx.xxxx.com: oracle set sender to [email protected] using -f
Nov 1 00:45:41 mylnx01 sendmail[17770]: v9VGjfnA017770: [email protected], size=17698, class=0, nrcpts=2, msgid=<[email protected]>, relay=oracle@localhost
Nov 1 00:45:41 mylnx01 sendmail[17771]: v9VGjfZ2017771: <[email protected]>... User unknown
Nov 1 00:45:41 mylnx01 sendmail[17771]: v9VGjfZ2017771: <[email protected]>... User unknown
Nov 1 00:45:41 mylnx01 sendmail[17770]: v9VGjfnA017770: [email protected], [email protected] (502/502), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=77698, relay=[127.0.0.1] [127.0.0.1], dsn=5.1.1, stat=User unknown
Nov 1 00:45:41 mylnx01 sendmail[17770]: v9VGjfnA017770: [email protected], [email protected] (502/502), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=77698, relay=[127.0.0.1] [127.0.0.1], dsn=5.1.1, stat=User unknown
Nov 1 00:45:41 mylnx01 sendmail[17771]: v9VGjfZ2017771: from=<[email protected]>, size=17698, class=0, nrcpts=0, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Nov 1 00:45:41 mylnx01 sendmail[17770]: v9VGjfnA017770: v9VGjfnB017770: DSN: User unknown
Nov 1 00:45:41 mylnx01 sendmail[17771]: v9VGjfZ4017771: <[email protected]>... User unknown
Nov 1 00:45:41 mylnx01 sendmail[17770]: v9VGjfnB017770: [email protected], delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=48722, relay=[127.0.0.1] [127.0.0.1], dsn=5.1.1, stat=User unknown
Nov 1 00:45:41 mylnx01 sendmail[17771]: v9VGjfZ4017771: from=<>, size=18722, class=0, nrcpts=0, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Nov 1 00:45:41 mylnx01 sendmail[17770]: v9VGjfnB017770: v9VGjfnC017770: return to sender: User unknown
Nov 1 00:45:41 mylnx01 sendmail[17771]: v9VGjfZ6017771: from=<>, size=22066, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Nov 1 00:45:41 mylnx01 sendmail[17770]: v9VGjfnC017770: to=postmaster, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=49746, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (v9VGjfZ6017771 Message accepted for delivery)
Nov 1 00:45:41 mylnx01 sendmail[17772]: v9VGjfZ6017771: to=root, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=52298, dsn=2.0.0, stat=Sent
出現這個問題的原因是因為在測試sendmail的一個功能時,在配置文件/etc/mail/local-host-names了設置了一些功能變數名稱,這個配置文件可以用它來實現虛擬功能變數名稱或多功能變數名稱支持,一般當主機有多個名稱時,而當你希望多個主機名都能收到郵件時,那麼就必須設置這個配置文件。
[root@mylnx01 log]# more /etc/mail/local-host-names
# local-host-names - include all aliases for your machine here.
xxxxx.com
而偏偏這台伺服器的hostname跟local-host-names裡面指定的不一樣。從而導致郵件發送異常問題。註釋掉這個主機名後,SendMail發送郵件就正常。
[root@mylnx01 log]# more /etc/mail/local-host-names
# local-host-names - include all aliases for your machine here.
#xxxxx.com
參考資料:
https://www.linuxquestions.org/questions/linux-newbie-8/sendmail-error-user-unknown-dsn%3D5-1-1-a-4175460428/
http://linux.vbird.org/linux_server/0380sendmail.php#server_local-host-names