But when I use Developer Tools to test “Notifications: Send a notification with fastmail” (entering a Message and Title, and just to be sure, specifying [email protected] as a target) I receive no email and HA logs in homeassistant.log:
The domain is one I own with email hosted at FastMail.com for years. The password is an app password I’m using elsewhere, but just to be sure I tested sending using the same settings above (copied and pasted) via CMail (CMail Command Line Mailer), which I use elsewhere with this account for alerting, and the email was sent successfully.
I specified “debug: true” but can’t find any info on where to find a SMTP debug log.
I’m a Python noob but my read of homeassistant/components/notify/smtp.py suggests that if there was a server or account problem HA would log a different exception before trying to send the message.
Thanks for the suggestion. I added that to my existing logger section, which is now
logger:
default: info
logs:
# log level for HA core
homeassistant.core: warning
# log level for MQTT integration
homeassistant.components.mqtt: warning
# log level for all python scripts
homeassistant.components.python_script: debug
# log level for notifications
homeassistant.components.notify: debug
I also added an explicit timeout: 5 to the SMTP settings, and restarted HA at least twice. But there are at most 2 additional log entries that don’t add any helpful info (to me, at least):
Looked to see if HA OS might have a firewall blocking outbound email. But eventually found iptables in use, with no outbound rules.
Checked the latest HA code and discovered that what I’d found earlier via Google must have been quite old, as the component that had been components/notify/smtp.py was now components/smtp/notify.py. So enabled debug logging for “homeassistant.components.smtp”. But this provided just additional one not-very-useful log entry.
Looked into how to override the core smtp component, so I could try to increase the logging in it. Eventually got this working, after figuring out how to override (via /config/custom_components), and how to download from git (one file at a time, using wget with raw URL), and the need to add an arbitrary “version” to manifest.json (not included in core components, but required for custom ones).
This showed me that the server was returning “SMTP code = 530, SMTP error = ‘5.7.1 Authentication required’” - despite my have configured authentication above.
So I added additional logging in notify.py which showed me that the username and password I’d entered weren’t being passed on to the SMTP notification.
Which had me look more closely at the notify: entry above, where I found I’d entered “user:” not “username:” (misread or mistyped?) and “password: lsecret” not “password !secret” (definitely misread).
After fixing these the notification is working, at least via Developer Tools.
Much learned, not least that I shouldn’t assume a successful Check Configuration means there aren’t syntax errors.
Thank you for giving such a detailed writeup, this helped me solve it.
For me the problem was more complicated, I didn’t have the permissions set correctly in AWS’s Simple Email Service I’m using, and was getting an error code 554.
I will probably submit a pull request to add more exception catching with more specific error messages for people in the future.