Java application is unable to send out JavaMail with error: "AuthenticationFailedException: No authentication mechansims supported by both server and client"
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6.x
- 7.x
Issue
Our Java application deployed on JBoss Enterprise Application Platform (EAP) 6 cannot send out mail with JavaMail.
We use "Sendmail" as SMTP server on Red Hat Enterprise Linux (RHEL).
The exception stacktrace on JBoss EAP side looks like this:
nested exception is javax.mail.AuthenticationFailedException: No authentication mechansims supported by both server and client
org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: No authentication mechansims supported by both server and client
at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:392) ~[spring-context-support-3.0.6.RELEASE.jar:3.0.6.RELEASE]
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:306) ~[spring-context-support-3.0.6.RELEASE.jar:3.0.6.RELEASE]
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:296) ~[spring-context-support-3.0.6.RELEASE.jar:3.0.6.RELEASE]
******
Caused by: javax.mail.AuthenticationFailedException: No authentication mechansims supported by both server and client
at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:756) ~[mail-1.4.4-redhat-1.jar!/:1.4.4-redhat-1]
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:669) ~[mail-1.4.4-redhat-1.jar!/:1.4.4-redhat-1]
at javax.mail.Service.connect(Service.java:295) ~[mail-1.4.4-redhat-1.jar!/:1.4.4-redhat-1]
And there is no log at all on "Sendmail" SMTP server side.
Diagnostic Steps
-
Increase logging level for SMTP server
If you are using "Sendmail" in RHEL please follow article: How to debug sendmail and increase the log level? to increase logging level and try to get some more logs on Sendmail side. -
Check if SMTP server requires authentication
- If authentication is not required on SMTP server side, please try to remove any username/password settings on mail client side (within Java application) and use mail.smtp.auth=false
- If SMTP server does require authentication, please try to set mail.smtp.auth=true and use correct username/password to connect.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
