Email sending thgouth home assistant no longer works

Hi all,

During the pass few days my home assistant setup in no longer sending emails using my gmail account. I have not changed my setup at all it just stop working for some reason. My automation is not sending emails out and the service notify.home_assistant_email is no longer available.

I have been trying for the pass few days to fix it but with no success. My configuration for gmail is the following:

  - name: "home_assistant_email"
    platform: smtp
    server: "smtp.gmail.com"
    port: 587
    timeout: 15
    sender: "[email protected]"
    encryption: starttls
    username: "[email protected]"
    password: "xxxxxxxxx"
    recipient:
      - "[email protected]"
    sender_name: "Home Assistant"

Does anyone knows if this is a bug or if something has change that made this integration to stop working? Do you see any problem with my configuration above?

Thanks

Phanos

If you are using an smtp server with normal authentication mechanisms (effectively bypassing 2 factor authentication) you need to have (the less secure) app passwords set up. The app passwords are reset when you change your Google password, or something else may have changes security to be stricter.
https://support.google.com/mail/answer/185833?hl=en

Also Google is phasing out app passwords, but I do not know if that apso applies to GMail yet:
https://support.google.com/accounts/answer/6010255?hl=en

Hi Edwin,

I do not have 2-factor authentication enabled I only use the normal username and password authentication method.

I believe you must be correct on your assumption since also on my iphone now I am getting authentication errors when trying to connect throughout caldev calendar on google so probably google must have changed something.
through google? Is the code above correct and I should simply enable 2-factor authentication on my google account and then instead of password use an app password instead?

Thanks

Phanos

I am having same issue as op. It seems google disabled this feature as of May 30, 2022.

What to do?

Update: I think we need to enable 2 factor authentication and create an app password.

2 Likes

Google is making 2 factor authentication required (for my family it already is) and forcing apps to use secure methods too, such as OAuth2. I would not expect them to be this strict for smtp to this soon, so hopelully you can still create an app password for that.

3 Likes

Thanks Edwin

I was able to create and app password and enable email capabilities in home assistant.
For now I can confirm that the above code with a app password (instead of the actual gmail password) works fine.

You just have to make sure you enable 2-factor authentication in gmail before you can create an app password for an app.

Phanos

1 Like

So how did you get the smtp service to initialize Home Assistant with Gmail after turning on 2FA?

Iā€™m unable to do it and get it initialized getting a Failed to initialize notification service smtp error in the logger and email notifications are of course still broken

Source: components/notify/legacy.py:77
Integration: Notifications (documentation, issues)
First occurred: 12:17:34 PM (1 occurrences)
Last logged: 12:17:34 PM

But did you create an app password for the service, as described in the link in the posts above?

:man_facepalming: missed that step
Now implemented the app password for the service - all good now, thank you!

FWIW, I encountered the same issue and mitigated it by switching the email account from using gmail to outlook (which still permits authentication via username and password).