Mail Binding - OH3.3 - Cannot send Email - javax.net.ssl.SSLHandshakeException

Hi all,

I’m running OH 3.3.0 in docker on a QNAP NAS and I am struggling with sending emails. I’ve read through a lot of similar threads in the community but could not find an answer.

This is my test script:

val mailActions = getActions(“mail”,“mail:smtp:mymail”)
mailActions.sendMail(“myemailaddress-replaced”, “Text Subject”, “Text body”)

The mail:smtp:mymail Thing is configured with SSL/TLS, port 465 and all the right DNS name and credentials that I successfully use also for other applications on the NAS for email notification (but not in docker containers).

This is the error I get in the log:

2022-07-06 13:36:21.386 [WARN ] [ab.binding.mail.internal.SMTPHandler] - javax.mail.MessagingException: Could not connect to SMTP host: hostname-replaced, port: 465;
nested exception is:
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

I guess it’s a “stupid” communication problem between the OpenHAB container and the mail server. I would not think it’s a general firewall, etc. issue in my home network because many other applications can send emails successfully, even on the NAS.

Regarding the docker config (NAT configuration), I would not expect that I have to open port 465 in the docker config because it’s communication initiated inside the container to the outside. Or am I wrong? Any other obvious things I may be missing and would need to check or configure?

In all likelihood your OH instance and your mail server do not share an encryption algorithm in common. Review openhab/openhab - Docker Image and pay attention to the CRYPTO_POLICY environment variable.

Thanks so much, Rich, excellent hint! I had to set CRYPTO_POLICY from “limited” to “unlimited” and now it works!

The javax.net.ssl.SSLHandshakeException in OH3.3 Mail Binding usually occurs due to Java’s default cryptography restrictions. To fix it, set the CRYPTO_POLICY=unlimited in your Java security settings (e.g., in java.security or via environment variable). This allows stronger TLS/SSL protocols required by modern mail servers.