![问题概述](https://linux22.com/image/697248/%E9%97%AE%E9%A2%98%E6%A6%82%E8%BF%B0.png)
问题概述
我正在进行 P2V 迁移,在使 tomcat 和 sendmail 正常运行方面遇到了障碍。我无法让应用程序发送邮件。
这两个系统之间的主要区别是:
- 操作系统正在从 CentOS 5.6 升级到 CentOS 7.2
- Sendmail 从 8.13.8 升级至 8.14.7
- Tomcat 以前以 root 身份运行,现在以 tomcat 身份运行
相同的设置(减去上述差异)当前正在物理环境中运行。
应用程序无需指定用户或密码即可连接。sendmail 配置中除了 sendmail.mc 中的以下内容外,没有其他任何内容可以设置身份验证:
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。
我已将以下内容放入我的 hosts 文件中:
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 中,LOGIN 是默认提供的。在 8.14 中,GSSAPI 似乎现在已默认提供。在重新启动 sendmail 后,/etc/mail/sendmail.mc 中的以下行允许从 tomcat 进行空白登录:
define(`confAUTH_MECHANISMS', `LOGIN')dnl