SMTP Notification Problems

Hi, all.
I’m having some difficulty with smtp notifications and am looking for some help.
I’m running the latest version of HA on an RPi 3B+.
There are 2 problems I’m facing:

  1. The first problem is that I can’t figure out how to get multiple notifiers configured and working roperly.
    Below is a section of my configuration.yaml file followed by a section from my automation.yaml file. You can see there are 3 notifiers seet up in configuration.yaml, all attempting to use the Google smtp server but sending to different recipients. The ‘name’ element is supposed to allow me to call services like ‘notify.jeff_phone’ or ‘notify.jeff_work’ in the automation.yaml file. Howver, the only service call that works at all is simply ‘notify.notify’, and then only the first notifier is used.
  2. The second problem is with multiple recipients in a notifier and this appears in the first notifier, below. There are both a regular email address and an email address that sends a text to my phone configured as recipients. Only the phone notification is working, not the regular email notification.

Anybody got any ideas on whawt I’m doing wrong?
Thanks.
Jeff

# Email notifications using gmail.
notify:
  - name: jeff_phone
    platform: smtp
    server: smtp.gmail.com
    port: 587
    timeout: 15
    sender: <name>@gmail.com
    encryption: starttls
    username: <name>@gmail.com
    password: !secret notify_jeff_password
    recipient:
      - <recipient_1>@comcast.net
      - <phone>@mymetropcs.com
    sender_name: My Home Assistant
    debug: true
  - name: jeff_work
    platform: smtp
    server: smtp.gmail.com
    port: 587
    timeout: 15
    sender: <name>@gmail.com
    encryption: starttls
    username: <name>@gmail.com
    password: !secret notify_jeff_password
    recipient:
      - <recipient_2>@yahoo.com
    sender_name: My Home Assistant
    debug: true
  - name: jeff_email
    platform: smtp
    server: smtp.gmail.com
    port: 587
    timeout: 15
    sender: <name>@gmail.com
    encryption: starttls
    username: <name>@gmail.com
    password: !secret notify_jeff_password
    recipient:
      - <recipient_3>@comcast.net
    sender_name: My Home Assistant
    debug: true
- alias: Notify - Exterior Door Opened
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.front_door_sensor
    from: 'off'
    to: 'on'
  condition:
    condition: state
    entity_id: person.jeff
    state: 'not_home'
  action:
  - service: notify.notify
    data_template:
      title: "HA Exterior Door Notification"
      message: "{{ trigger.from_state.attributes.alias }} has been opened."

Are you sure you’re restarting HA when you change these files?

FWIW, here is what I use with Gmail:

notify:
  - name: email_phil
    platform: smtp
    sender: !secret notify_snd_email_username
    recipient: !secret notify_phil_email_address
    server: smtp.gmail.com
    username: !secret notify_snd_email_username
    password: !secret notify_snd_email_password
    sender_name: Home Assistant
  - name: mms_phil
    platform: smtp
    sender: !secret notify_snd_email_username
    recipient: !secret notify_phil_mms_address
    server: smtp.gmail.com
    username: !secret notify_snd_email_username
    password: !secret notify_snd_email_password

The first one goes to my Gmail account, and the second effectively goes as an MMS message to my phone. And, the services are named notify.email_phil and notify.mms_phil.

1 Like

Well, things are working now. It turns out I needed to enable less secure apps to use my Google account for sending emails, so the SMTP service was never initializing properly and my notifier services were never being registered as services in HA. Once I got tthat working and saw the notifier services getting properly registered and working I re-disabled the less secure apps, set up a dedicated Google account for HA email notifications, and configured it to allow use by the less secure apps.
A curious thing that I haven’t yet figured out, though…In my original setup, even though the SMTP initialization never completed properly (I found how to see that in the HA logs, and then could verify ‘working’ vs. ‘not working’), my phone would still ding at me and the notifications would show up (even though none of the emails were working); and then once I got the SMTP working properly my phone stopped dinging and showing the notifications. It still gets the text messages, and I can see them by opening up ‘Messages’, but it stopped alerting me of their arrivals. I think I may have now gotten that set up in the notifications setting on my phone, but it is curious that phone alerts were originally working even though SMTP appeared not to be, and then the alerts stopped when I got SMTP working.
Progress, leading to further questions - one of the spices of life, right?
Thanks, Phil. I really appreciated your taking the time to get back to me.
Jeff

1 Like

Yep, I have a separate gmail account I use for SMTP notification, which, as you discovered, needs to enable less secure apps. Sorry, I assumed you would know that.

The other part you describe (about the notifications on the phone) does indeed seem strange. I definitely get notifications when the MMS messages arrive.