I have created a free-standing Google account with its own Gmail service. I want to use these with the SMTP integration so I do not have to compromise the security of my personal Google account.
From config.yaml:
notify:
- name: "Cheap slots warning"
platform: smtp
sender: !secret tregeada_sender
recipient: !secret tregeada_recipient
server: smtp.gmail.com
username: !secret tregeada_username
password: "!secret tregeada_password"
debug: true
port: 587
encryption: starttls
Initially I set up the new Google account without 2FA instead using the username and password authentication. The connection failed. In the logs “535, b’5.7.8 Username and Password not accepted” told me that 2FA was set up on the target account. Strange?
Next, I created an app password for my personal Google account and changed the notifier config so that my personal Google account was the target. Success (sort of)! Using Developer Tools / Service I was able to send emails to myself.
Finally, I added 2FA and an app password to the new Google account and changed the notifier config setting the new Google account as the target. The connection failed. Here is the detail from the logs:
2023-06-20 10:58:23.164 ERROR (SyncWorker_4) [homeassistant.components.smtp.notify] Login not possible. Please check your setting and/or your credentials
Traceback (most recent call last):
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 155, in connect
mail.login(self.username, self.password)
File "/usr/local/lib/python3.11/smtplib.py", line 750, in login
raise last_exception
File "/usr/local/lib/python3.11/smtplib.py", line 739, in login
(code, resp) = self.auth(
^^^^^^^^^^
File "/usr/local/lib/python3.11/smtplib.py", line 662, in auth
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (534, b'5.7.9 Please log in with your web browser and then try again. Learn more at\n5.7.9 https://support.google.com/mail/?p=WebLoginRequired z12-20020a05600c114c00b003f9b4330880sm1904399wmz.29 - gsmtp')
So, I can only use SMTP if I compromise the security of my personal Google account?
Any and all help very gratefully received.