問題概述
我正在進行 P2V 遷移,但在讓 tomcat 和 sendmail 正常運作方面遇到了障礙。我無法獲得發送郵件的應用程式。
兩個系統之間的主要區別是:
- 作業系統正在從 CentOS 5.6 升級到 CentOS 7.2
- Sendmail從8.13.8升級到8.14.7
- Tomcat 以前以 root 身份運行,現在以 tomcat 身份運行
當前物理環境中正在運行相同的設定(減去上述差異)。
應用程式無需指定使用者或密碼即可進行連線。除了 sendmail.mc 中的以下內容之外,sendmail 配置中沒有其他設定身份驗證的內容:
define(`confAUTH_OPTIONS', `A')dnl
紀錄
我從 catalina.out 得到的關鍵錯誤是:
Caused by: javax.mail.AuthenticationFailedException: No authentication mechansims supported by both server and client
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:590)
at javax.mail.Service.connect(Service.java:291)
at javax.mail.Service.connect(Service.java:172)
at com.tw.manage.business.services.MailService.sendMessage(MailService.java:97)
反編譯的 com.tw.manage.business.services.MailService.sendMessage 程式碼位於此處。
相關的app.properties在這裡:
# Mail properties
# ---------------
# email server host
mailer.smtp.host=localhost
# email server port
mailer.smtp.port=25
# protocol either smtp or smtps
mailer.protocol=smtp
# user account
mailer.user=
# user password
mailer.password=
# either text/plain or text/html
mailer.mime.type=text/html;charset=UTF-8
mailer.subject.mime.type=UTF-8
# email message from email address
[email protected]
這是 /var/log/maillog 中的錯誤:
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: assigned id
Jan 18 14:02:40 app-server sendmail[46298]: NOQUEUE: connect from localhost.localdomain [127.0.0.1]
Jan 18 14:02:40 app-server sendmail[46298]: AUTH: available mech=GSS-SPNEGO GSSAPI ANONYMOUS, allowed mech=EXTERNAL GSSAPI KERBEROS_V4 DIGEST-MD5 CRAM-MD5
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: Milter: no active filter
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: --- 220 app-server.company.inc ESMTP Sendmail 8.14.7/8.14.7; Wed, 18 Jan 2017 14:02:40 -0500
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: <-- EHLO app-server
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: --- 250-app-server.company.inc Hello localhost.localdomain [127.0.0.1], pleased to meet you
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: --- 250-ENHANCEDSTATUSCODES
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: --- 250-PIPELINING
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: --- 250-8BITMIME
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: --- 250-SIZE
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: --- 250-DSN
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: --- 250-ETRN
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: --- 250-AUTH GSSAPI
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: --- 250-DELIVERBY
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: --- 250 HELP
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: disconnect level 1
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: in background, pid=46298
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: --- 421 4.4.1 app-server.company.inc Lost input channel from localhost.localdomain [127.0.0.1]
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: lost input channel from localhost.localdomain [127.0.0.1] to MTA after ehlo
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: disconnect level 1
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: in background, pid=46298
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: localhost.localdomain [127.0.0.1] did not issue MAIL/EXPN/VRFY/ETRN during connection to MTA
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: dropenvelope, e_flags=0x4001, OpMode=d, pid=46298
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: unlink ./dfv0IJ2exL046298
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: ./dfv0IJ2exL046298: unlink-fail 2
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: unlink ./qfv0IJ2exL046298
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: ./qfv0IJ2exL046298: unlink-fail 2
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: unlock
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: unlink ./xfv0IJ2exL046298
Jan 18 14:02:40 app-server sendmail[46298]: v0IJ2exL046298: ./xfv0IJ2exL046298: unlink-fail 2
Jan 18 14:02:40 app-server sendmail[46298]: NOQUEUE: finis, pid=46298
我嘗試過的事情
/etc/mail 中的所有設定都是相同的。我已經驗證不需要更改環境,例如主機名稱 - 配置僅呼叫 localhost 或 localhost.localdomain。
我已將以下內容放入我的主機文件中:
127.0.0.1 localhost.localdomain localhost old-app-hostname.vendor.net app-server app-server.company.inc
我已經測試過使用 root 和其他本機帳戶發送郵件telnet localhost 25
,並且能夠使用所需的電子郵件地址從伺服器接收我的 gmail 中的郵件。
我還嘗試過以 root 身份運行 tomcat。
答案1
我發現預設選項一定已經改變了。在 sendmail 8.13 中,預設提供登入。在 8.14 中,似乎現在預設提供 GSSAPI。重新啟動 sendmail 後,/etc/mail/sendmail.mc 中的以下行允許從 tomcat 進行空白登入:
define(`confAUTH_MECHANISMS', `LOGIN')dnl