diff --git a/source/_components/notify.smtp.markdown b/source/_components/notify.smtp.markdown index d5f33126c8a..d12935b15bc 100644 --- a/source/_components/notify.smtp.markdown +++ b/source/_components/notify.smtp.markdown @@ -35,8 +35,9 @@ Configuration variables: - **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*): E-mail address of the recipient of the notification. This can be a recpient address or a list of addresses for multiple recipients. +- **recipient** (*Required*): E-mail address of the recipient of the notification. This can be a recipient address or a list of addresses for multiple recipients. - **starttls** (*Optional*): Enables STARTTLS, eg. True or False. Defaults to False. +- **sender_name** (*Optional*): Sets a custom 'sender name' in the emails headers (*From*: Custom name ). - **debug** (*Optional*): Enables Debug, eg. True or False. Defaults to False. A sample configuration entry for Google Mail. @@ -56,6 +57,7 @@ notify: recipient: - james@gmail.com - bob@gmail.com + sender_name: My Home Assistant ``` Keep in mind that Google has some extra layers of protection which need special attention (Hint: 'Less secure apps'). @@ -63,7 +65,7 @@ Keep in mind that Google has some extra layers of protection which need special To use the SMTP notification, refer to it in an automation or script like in this example: ```yaml - burglar: + burglar: alias: Burglar Alarm sequence: - service: shell_command.snapshot @@ -74,13 +76,80 @@ To use the SMTP notification, refer to it in an automation or script like in thi title: 'Intruder alert' message: 'Intruder alert at apartment!!' data: - images: + images: - /home/pi/snapshot1.jpg - /home/pi/snapshot2.jpg ``` The optional `images` field adds in-line image attachments to the email. This sends a text/HTML multi-part message instead of the plain text default. +The optional `html` field makes a custom text/HTML multi-part message, allowing total freedom for sending rich html emails. In them, if you need to attach images, you can pass both arguments (`html` and `images`), the attachments will be joined with the basename of the images, so they can be included in the html page with `src="cid:image_name.ext"`. + +```yaml + burglar: + alias: Burglar Alarm + sequence: + - service: shell_command.snapshot + - delay: + seconds: 1 + - service: notify.NOTIFIER_NAME + data_template: + message: 'Intruder alert at apartment!!' + data: + images: + - /home/pi/snapshot1.jpg + - /home/pi/snapshot2.jpg + html: > + + + + + + + Intruder alert + + + + + +
+
+

Intruder alert at apartment!!

+
+
+
+
+
+ snapshot1 +
+
+ snapshot2 +
+
+
+
+ + + + + +``` +Obviously, this kind of complex html email reporting is done much more conveniently using Jinja2 templating from an [AppDaemon app](https://home-assistant.io/docs/ecosystem/appdaemon/tutorial/), for example. + 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.