Help With SMTP

I’m having trouble getting SMTP working. I’ve been working on this for weeks but can’t seem to get it up and running. I have edited the config.yaml file to include the parameters for my email domain.

notify:

  • name: smtpmail
    platform: smtp
    server: mail40.newtekwebhosting.com
    port: 465
    timeout: 15
    sender: !secret notification_sender
    starttls: true
    encryption: starttls
    username: !secret notification_username
    password: !secret notification_password
    recipient: !secret notification_recipient
    sender_name: Home Assistant
    verify_ssl: true

Using the startup log I found that SMTP errors-out on load and suspends running. The system log produces the following error log. Does anyone have some guidance on how to interpret this report?

Logger: homeassistant.components.notify
Source: components/notify/legacy.py:108
integration: Notifications (documentation, issues)
First occurred: 5:56:52 PM (1 occurrences)
Last logged: 5:56:52 PM

Error setting up platform smtp
Traceback (most recent call last):
File “/usr/local/lib/python3.13/smtplib.py”, line 398, in getreply
line = self.file.readline(_MAXLINE + 1)
File “/usr/local/lib/python3.13/socket.py”, line 719, in readinto
return self._sock.recv_into(b)
~~~~~~~~~~~~~~~~~~~~^^^
TimeoutError: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/notify/legacy.py”, line 108, in async_setup_platform
notify_service = await hass.async_add_executor_job(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
platform.get_service, hass, p_config, discovery_info
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File “/usr/local/lib/python3.13/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 103, in get_service
if mail_service.connection_is_valid():
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File “/usr/src/homeassistant/homeassistant/components/smtp/notify.py”, line 165, in connection_is_valid
server = self.connect()
File “/usr/src/homeassistant/homeassistant/components/smtp/notify.py”, line 151, in connect
mail = smtplib.SMTP(self._server, self._port, timeout=self._timeout)
File “/usr/local/lib/python3.13/smtplib.py”, line 255, in init
(code, msg) = self.connect(host, port)
~~~~~~~~~~~~^^^^^^^^^^^^
File “/usr/local/lib/python3.13/smtplib.py”, line 343, in connect
(code, msg) = self.getreply()
~~~~~~~~~~~~~^^
File “/usr/local/lib/python3.13/smtplib.py”, line 401, in getreply
raise SMTPServerDisconnected("Connection unexpectedly closed: "
+ str(e))
smtplib.SMTPServerDisconnected: Connection unexpectedly closed: timed out

try to change to verify_ssl: false that worked for me

Did you try port: 587 already?

Thank you for suggestions. I tried using port 587 and setting “verify_ssl=false”, but I get the same error on start-up. Port 587 is used for non-SSL servers, but my hosting provider uses an SMTP server that requires port 465 and uses and encrypted SSL port.

What I don’t know how to interpret the error codes associated with the error log that includes reports that reference Python lines of code errors, like:

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/notify/legacy.py”, line 108, in async_setup_platform
notify_service = await hass.async_add_executor_job(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If you have any idea how to interpret error reports, I’d appreciate any suggestions, or if you know who I might contact to get detailed support for errors like this that would be great.

Thank you!

That’s a stack trace, it’s a line by line history where the error occurs in your file. ALl you need to care about is the last line, which is your actual error. The rest is so developers can identify in the code where the error occured.

This is all you need to look at. The connection to it is timing out, which typically means it can’t be reached.

Thank you for your guidance… I will check with my hosting service to see if they can help me understand why the server connection is timing out. I use the same settings for my Microsoft Outlook connection to my SMTP mail server and it has worked for many years.

it’s more likely that HA can’t reach it. I’d start by looking at your network, and verify what the server requires in regards to connection. Either way, don’t focus on the stack trace.

@dlstillmaker Thanks for the tip, I was about to submit an issue. I haven’t traced the code and I’m not planning on it right now. I believe a library was updated which added additional latency in 2024.10 and caused my issues.