### The problem
Starting in 2024.1, my SMTP integration is no longer working.… It worked fine in 2023.12, but since 2024.1, I have to set `verify_ssl: false` or I get a stack trace when I try to send an email.
### What version of Home Assistant Core has the issue?
2024.1
### What was the last working version of Home Assistant Core?
2023.12
### What type of installation are you running?
Home Assistant OS
### Integration causing the issue
SMTP
### Link to integration documentation on our website
https://www.home-assistant.io/integrations/smtp/
### Diagnostics information
_No response_
### Example YAML snippet
```yaml
notify:
- name: "SMTP Notifications"
platform: smtp
sender: "homeassistant@example.com"
unique_id: smtp_notifications
recipient:
- alex@example.com
server: smtp.fastmail.com
port: 465
encryption: tls
username: alex@example.com
password: !secret alex_smtp_password
sender_name: Ives Home
### Currently working
- name: "Working SMTP Notifications"
platform: smtp
sender: "homeassistant@example.com"
unique_id: smtp_notifications
recipient:
- alex@example.com
server: smtp.fastmail.com
port: 465
encryption: tls
username: alex@example.com
password: !secret alex_smtp_password
sender_name: Ives Home
verify_ssl: false
```
### Anything in the logs that might be useful for us?
Error on reload after removing `verify_ssl: true` from the config.
```txt
Logger: homeassistant.components.notify
Source: components/notify/legacy.py:94
Integration: Notifications (documentation, issues)
First occurred: 10:34:35 AM (4 occurrences)
Last logged: 10:43:29 AM
Error setting up platform smtp
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/notify/legacy.py", line 94, in async_setup_platform
notify_service = await hass.async_add_executor_job(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/smtp/notify.py", line 102, in get_service
if mail_service.connection_is_valid():
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/smtp/notify.py", line 164, in connection_is_valid
server = self.connect()
^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/smtp/notify.py", line 143, in connect
mail = smtplib.SMTP_SSL(
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/smtplib.py", line 1050, in __init__
SMTP.__init__(self, host, port, local_hostname, timeout,
File "/usr/local/lib/python3.11/smtplib.py", line 255, in __init__
(code, msg) = self.connect(host, port)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/smtplib.py", line 341, in connect
self.sock = self._get_socket(host, port, self.timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/smtplib.py", line 1057, in _get_socket
new_socket = self.context.wrap_socket(new_socket,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/ssl.py", line 517, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/ssl.py", line 1108, in _create
self.do_handshake()
File "/usr/local/lib/python3.11/ssl.py", line 1379, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL] unknown error (_ssl.c:1006)
```
Error on trying to send (only possible if I restart, since the yaml reload checks the connection)
```txt
Logger: homeassistant.components.websocket_api.http.connection
Source: components/smtp/notify.py:143
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 10:30:39 AM (3 occurrences)
Last logged: 10:30:52 AM
[547303142848] Error handling message: Unknown error (unknown_error) Alex from 192.168.1.203 (Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:122.0) Gecko/20100101 Firefox/122.0)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
await func(hass, connection, msg)
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 782, in handle_execute_script
script_result = await script_obj.async_run(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1587, in async_run
return await asyncio.shield(run.async_run())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 426, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 479, in _async_step
self._handle_exception(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 502, in _handle_exception
raise exception
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 713, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 675, in _async_run_long_action
return long_task.result()
^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2149, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2186, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/notify/legacy.py", line 265, in _async_notify_message_service
await self.async_send_message(**kwargs)
File "/usr/src/homeassistant/homeassistant/components/notify/legacy.py", line 241, in async_send_message
await self.hass.async_add_executor_job(
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/smtp/notify.py", line 223, in send_message
return self._send_email(msg, recipients)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/smtp/notify.py", line 227, in _send_email
mail = self.connect()
^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/smtp/notify.py", line 143, in connect
mail = smtplib.SMTP_SSL(
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/smtplib.py", line 1050, in __init__
SMTP.__init__(self, host, port, local_hostname, timeout,
File "/usr/local/lib/python3.11/smtplib.py", line 255, in __init__
(code, msg) = self.connect(host, port)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/smtplib.py", line 341, in connect
self.sock = self._get_socket(host, port, self.timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/smtplib.py", line 1057, in _get_socket
new_socket = self.context.wrap_socket(new_socket,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/ssl.py", line 517, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/ssl.py", line 1108, in _create
self.do_handshake()
File "/usr/local/lib/python3.11/ssl.py", line 1379, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL] unknown error (_ssl.c:1006)
```
### Additional information
Originally I thought this might be related to https://github.com/home-assistant/core/issues/107369, but it seems that's resolved.