I’m trying to setup SMTP for the first time in HA. I’ve gone through tons of documentation on smtp, looked up the errors that I’m receiving but just can’t find what is wrong.
After I couldn’t get the setup to work in HA, I wrote a simple AutoHotkey script to test all of the settings that I’m using to connect to my gmail account. Using the ahk script I was able to connect and send an email without any problems.
Here’s what I have in my configuration.yaml:
notify:
- name: gmail_smtp
platform: smtp
sender: [email protected]
recipient: [email protected]
server: smtp.gmail.com
port: 465
timeout: 60
username: [email protected]
password: appKeyPwd
# encryption: starttls
#sendername: [email protected]
verify_ssl: true
debug: true
# not listed in doc: https://www.home-assistant.io/integrations/smtp/
#starttls: true
note: I’ve tried the above with and without the encryption.
Here are the errors from my log file:
Logger: homeassistant.components.notify
Source: components/smtp/notify.py:148
Integration: Notifications (documentation, issues)
First occurred: 4:29:28 PM (1 occurrences)
Last logged: 4:29:28 PM
Error setting up platform smtp
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/notify/legacy.py", line 93, 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 100, in get_service
if mail_service.connection_is_valid():
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/smtp/notify.py", line 162, in connection_is_valid
server = self.connect()
^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/smtp/notify.py", line 148, in connect
mail = smtplib.SMTP(self._server, self._port, timeout=self._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 343, in connect
(code, msg) = self.getreply()
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/smtplib.py", line 405, in getreply
raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed
Your help/suggestions would be greatly appreciated!