SMTP - No Service being Created

Trying to set-up an e-mail Notify in yaml configuration file and I did have a service listed once, but the send failed. I’ve since tried various formats to try to get the notification working, but now I’ve completely lost the service.

My yaml reads as follows:

notify:

My error log reads as follows:

Error setting up platform smtp
Traceback (most recent call last):
File “/usr/local/lib/python3.10/smtplib.py”, line 398, in getreply
line = self.file.readline(_MAXLINE + 1)
File “/usr/local/lib/python3.10/socket.py”, line 705, 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 93, in async_setup_platform
notify_service = await hass.async_add_executor_job(
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/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.10/smtplib.py”, line 255, in init
(code, msg) = self.connect(host, port)
File “/usr/local/lib/python3.10/smtplib.py”, line 343, in connect
(code, msg) = self.getreply()
File “/usr/local/lib/python3.10/smtplib.py”, line 401, in getreply
raise SMTPServerDisconnected("Connection unexpectedly closed: "
smtplib.SMTPServerDisconnected: Connection unexpectedly closed: timed out

I wish someone would create a SMTP blueprint.

Ditto. Okay. After trying for hours, I did get it to relist as a “Service” and it actually worked. Code reads as follows for those with private domain accounts (e.g., namecheap):

notify:

I am not (yet ???) comfortable with Yaml and keep getting errors. I really wish someone would design SMTP steps for simple HA beginners like me, preferably using Visual Editor.

I found this a little helpful -

I tried that but keep getting error messages

Maybe I can help. It’s clear in my head. Let’s see your configuration yaml file

That would be great. If you don’t mind, I’ll send it to you tomorrow, as I deleted it from my Yaml configuration and it is bed time here in Miami :slight_smile:

This is what I have :

notify:
  - name: pushover
    platform: pushover
    api_key:  xxxxxxxxxx
    user_key: yyyyyyyyyy
  - name: "NOTIFIER_NAME"
    platform: smtp
    sender: [email protected]
    recipient: [email protected]
    Server: smtp.office365.com
    Port: 587
    timeout: 5
    username: [email protected]
    password: "zzzzzzzzz"
    Encryption: STARTTLS
    sender_name: HA

In Call Service - Notify no email option shows

Let’s try to simplify it first just to see if you get it listed in service. Change it to:

notify:

After changing the yaml, go to system, reboot, YAML only. Then Developer, Services and see if you can find it.

You might also need to change encryption to starttls, but try mine first.

No luck yet :frowning_face:

- platform: smtp
    name: send_email_message
    server: smtp.office365.com
    Port: 587
    sender: [email protected]
    encryption: tls
    username: [email protected]
    password: xxxxxxx
    recipient: [email protected]

I changed password to an app specific password

Try starttls encryption. You might also want to try another e-mail service if you have one.