core: SSL error when setting up IMAP email sensors

The problem

Email sensor configuration causes error messages to be thrown in the log, see below, suggesting SSL errors.

Sensors do not get created

What version of Home Assistant Core has the issue?

2022.10.1

What was the last working version of Home Assistant Core?

Not sure how long ago it stopped working

What type of installation are you running?

Home Assistant Container

Integration causing the issue

IMAP Email Content

Link to integration documentation on our website

https://www.home-assistant.io/integrations/imap_email_content/

Diagnostics information

No response

Example YAML snippet

sensor
  - platform: imap_email_content
    server: <imap server>
    name: emailsensor
    port: 993
    verify_ssl: false
    username: !secret email_username
    password: !secret email_password
    senders:
      - no-reply@<email address>
    value_template: >-
      {% if '<text to check>' in body %}
        Case1
      {% else %}
        Case2
      {% endif %}

Anything in the logs that might be useful for us?

2022-10-06 22:40:45.360 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up imap_email_content platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/imap_email_content/sensor.py", line 74, in setup_platform
    sensor = EmailContentSensor(
  File "/usr/src/homeassistant/homeassistant/components/imap_email_content/sensor.py", line 175, in __init__
    self.connected = self._email_reader.connect()
  File "/usr/src/homeassistant/homeassistant/components/imap_email_content/sensor.py", line 105, in connect
    self.connection = imaplib.IMAP4_SSL(
  File "/usr/local/lib/python3.10/imaplib.py", line 1323, in __init__
    IMAP4.__init__(self, host, port, timeout)
  File "/usr/local/lib/python3.10/imaplib.py", line 202, in __init__
    self.open(host, port, timeout)
  File "/usr/local/lib/python3.10/imaplib.py", line 1336, in open
    IMAP4.open(self, host, port, timeout)
  File "/usr/local/lib/python3.10/imaplib.py", line 312, in open
    self.sock = self._create_socket(timeout)
  File "/usr/local/lib/python3.10/imaplib.py", line 1327, in _create_socket
    return self.ssl_context.wrap_socket(sock,
  File "/usr/local/lib/python3.10/ssl.py", line 513, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/local/lib/python3.10/ssl.py", line 1071, in _create
    self.do_handshake()
  File "/usr/local/lib/python3.10/ssl.py", line 1342, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:997)

Additional information

IMAP server responds to email clients on same port from same network with no issues No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 23 (14 by maintainers)

Most upvoted comments

The rest solution looks ok. If that works I think that’s good. Regardless, I think we can add an option, but mark it as advanced.