I have the same problem with gmail. I am using an app password. I am sure the user / password combination is working, since it is working with get-mail. But in HA i get the following error in the logs:
Logger: homeassistant.components.sensor
Source: components/imap_email_content/sensor.py:105
Integration: Sensor (documentation, issues)
First occurred: 2:49:51 PM (1 occurrences)
Last logged: 2:49:51 PM
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 293, 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 1326, in _create_socket
sock = IMAP4._create_socket(self, timeout)
File "/usr/local/lib/python3.10/imaplib.py", line 302, in _create_socket
return socket.create_connection(address)
File "/usr/local/lib/python3.10/socket.py", line 824, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "/usr/local/lib/python3.10/socket.py", line 955, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name does not resolve
does anyone have the same problem? What can I do to solve it?
Update Solution:
It seems the problem was that I did not set a folder. According to the documentation it is not needed and the default is INBOX. But in reality I had to set the folder. And be careful not to have any spaces after the folder name.