smtp platform allows you to deliver notifications from Home Assistant to an e-mail recipient.
To enable notification by e-mail in your installation, add the following to your
# Example configuration.yaml entry notify: - name: NOTIFIER_NAME platform: smtp server: MAIL_SERVER recipient: YOUR_RECIPIENT
- name (Optional): Setting the optional parameter
nameallows multiple notifiers to be created. The default value is
notify. The notifier will bind to the service
- server (Optional): SMTP server which is used to end the notifications. Defaults to
- port (Optional): The port that the SMTP server is using. Defaults to 25.
- sender (Optional): E-mail address of the sender.
- username (Optional): Username for the SMTP account.
- password (Optional): Password for the SMTP server that belongs to the given username. If the password contains a colon it need to be wrapped in apostrophes.
- recipient (Required): Recipient of the notification.
- starttls (Optional): Enables STARTTLS, eg. True or False. Defaults to False.
- debug (Optional): Enables Debug, eg. True or False. Defaults to False.
A sample configuration entry for Google Mail.
# Example configuration.yaml entry notify: - name: NOTIFIER_NAME platform: smtp server: smtp.gmail.com port: 587 sender: email@example.com starttls: true username: firstname.lastname@example.org password: thePassword recipient: email@example.com
Keep in mind that Google has some extra layers of protection which need special attention (Hint: ‘Less secure apps’).
To use the SMTP notification, refer to it in an automation or script like in this example:
burglar: alias: Burglar Alarm sequence: - service: shell_command.snapshot - delay: seconds: 1 - service: notify.NOTIFIER_NAME data: title: 'Intruder alert' message: 'Intruder alert at apartment!!' data: images: - /home/pi/snapshot1.jpg - /home/pi/snapshot2.jpg
images field adds in-line image attachments to the email. This sends a text/HTML multi-part message instead of the plain text default.
This platform is fragile and not able to catch all exceptions in a smart way because of the large number of possible configuration combinations.
A combination that will work properly is port 587 and STARTTLS. It’s recommended to enable STARTTLS, if possible.
Keep in mind that if the password contains a colon, it needs to be wrapped in apostrophes in the
For Google Mail (smtp.gmail.com) an additional step in the setup process is needed. Google has some extra layers of protection which need special attention. By default, the usage by external applications, especially scripts, is limited. Visit the Less secure apps page and enable it.
To use notifications, please see the getting started with automation page.