Non-gmail smtp

I’m a newbie, trying to use a non-gmail smtp server (due to gmail’s restrictions). Here is what my service looks like:

notify:
  - name: smpt_text_email_charter
    platform: smtp
    server: mobile.charter.net
    port: 587
    timeout: 25
    sender: me@someplace
    encryption: starttls
    username: my_user
    password: my_pass
    recipient:
      - [email protected]
      - [email protected]
      - [email protected]
    sender_name: My Home Assistant

Here’s my automation:

- id: '1615404312568'
  alias: smtp test
  description: ''
  trigger: []
  condition: []
  action:
  - service: notify.smpt_text_email_charter
    data:
      message: Plug in Tesla
      title: Alarm
  mode: single

Here’s the log output:

2021-03-10 13:40:51 ERROR (MainThread) [homeassistant.components.notify] Error setting up platform smtp
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/smtplib.py", line 389, in getreply
    line = self.file.readline(_MAXLINE + 1)
  File "/usr/local/lib/python3.8/socket.py", line 669, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/notify/__init__.py", line 298, in async_setup_platform
    notify_service = await hass.async_add_executor_job(
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/smtp/notify.py", line 87, in get_service
    if mail_service.connection_is_valid():
  File "/usr/src/homeassistant/homeassistant/components/smtp/notify.py", line 141, in connection_is_valid
    server = self.connect()
  File "/usr/src/homeassistant/homeassistant/components/smtp/notify.py", line 127, in connect
    mail = smtplib.SMTP(self._server, self._port, timeout=self._timeout)
  File "/usr/local/lib/python3.8/smtplib.py", line 253, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/local/lib/python3.8/smtplib.py", line 339, in connect
    (code, msg) = self.getreply()
  File "/usr/local/lib/python3.8/smtplib.py", line 392, in getreply
    raise SMTPServerDisconnected("Connection unexpectedly closed: "
smtplib.SMTPServerDisconnected: Connection unexpectedly closed: timed out

Any suggestions appreciated. I can make this work using Go.

changed my automation:

- id: '1615404312568'
  alias: smtp_test_charter
  description: ''
  trigger: []
  condition: []
  action:
  - service: notify.smtp_text_email_charter
    data:
      message: Plug in Tesla
      title: Alarm
  mode: single

Log gives:

2021-03-10 19:59:54 ERROR (MainThread) [homeassistant.components.automation.smtp_test_charter] smtp_test_charter: Error executing script. Service not found for call_service at pos 1: Unable to find service notify.smtp_text_email_charter
2021-03-10 19:59:54 ERROR (MainThread) [homeassistant.components.automation.smtp_test_charter] Error while executing automation automation.smtp_test_charter: Unable to find service notify.smtp_text_email_charter

My service is not listed anywhere. Tried restarting several times. Works the same way for gmail.

I can reproduce this error message, when I alter the data für my notify service, for example when using wrong credentials, like wrong username or password (smtp with gmail):

Service not found for call_service at pos 1: Unable to find service notify.send_email

ps

username: my_user
password: my_pass

charternet wants a smtp email-address, not just an username. Just in case…

Thanks for your reply. I’ve checked credentials and they are correct. Also tried gmail (different credentials). Same failure. The interesting thing is that the service defined in my configuration.yaml does not appear in my list of services for the automation UI.

This is what happens, when something is wrong with the definition of the notify service: here the SMTP service is not generated and by this won’t show up.

I have two notify.send_email* services defined. When I change the loginname to something else (not valid) I get this:


As you can see: no notify.send_email

As soon the definition was corrected (right email address):

You might give us your real values of the notify service, for example this

sender: me@someplace

is not accepted and I can’t tell if you just show it this way because you want to hide the real address or you really using this.

If you don’t want to show email addresses at least post the correct domain names and put it like this
my_address**@gmail.com** or my_name**@arcor.de**.

I used your definition and change the values to my gmail server credentials:

  - name: smpt_text_email_charter
    platform: smtp
    server: smtp.gmail.com
    port: 587
    timeout: 25
    sender: [email protected]
    encryption: starttls
    username: !secret gmail_user
    password: !secret gmail_password
    recipient:
      - [email protected]
      - [email protected]
    sender_name: My Home Assistant

and it works like charm.

name: smtp_text_email_charter
    platform: smtp
    server: mobile.charter.net
    port: 587
    timeout: 15
    sender: ***[email protected]
    encryption: starttls
    username: ***[email protected]
    password: 34******
    recipient:
      - ****@gmail.com
      - ****[email protected]
      - ****[email protected]

Maybe it’s not the credentials. Maybe it is the port or encryption.

I tried changing the encryption to TLS. That caused the service to load. Still lots of diagnostics at restart but no “unable to find service” message. Nothing happens when I run the automation.

Hm, I am out of ideas. Maybe there is a need to fill something into the data field?

Or try to switch to gmail again and see if its working. btw: what are the restrictions of gmail you are talking about?

I switched to notify.events - maybe this is solution for you? 300 messages/month are free.

I wonder if Nabu Casa has ever contemplated on offering an outgoing email service as part of the Nabu Casa subscription. Ping @balloob :).

2 Likes

Tried gmail again and it works now. No idea what changed. I’ll go with it. I don’t like reducing the security level of apps with Google. This process reverses if no apps access for a period.

1 Like

We won’t add this. Email is no fun. Attracts too many spammers and there are enough services that offer this.

1 Like

What services provide outgoing email?

Maybe Paulus meant notify services.

As I said before one of them is a HA integration called notify.events
You decide if you want to receive an email and/or a SMS and/or get a browser notification:
grafik
and/or a notification to the Android of your mobile and lots of other possibilities:

Since I knew about notify.events I prefer this over sending mails out via SMTP. It’s much faster than sending out and receiving an email.
For example sending a notification to the app on my mobile or as browser notification takes ~1.6 sec from triggering a script until it pops up at my mobile or my browser on my PC.

It might even work with your charter.net account.

Fair enough. Having administered a few enterprise-grade email servers over the years I can definitely understand the pain, and the choice to not go down that rabbit hole :slight_smile:. Thanks for the fast response.

1 Like