Skip to content

Commit

Permalink
Added automation example.
Browse files Browse the repository at this point in the history
New example removes attachments to make it easier to follow.

Clarified how the integration will appear when trying to call it in a script/automation.
  • Loading branch information
dannytsang committed Apr 19, 2024
1 parent f1df617 commit d74e245
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions source/_integrations/smtp.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ notify:
recipient: "YOUR_RECIPIENT"
```
Check your email provider configuration or help pages to get the correct SMTP settings.
Check your email provider configuration or help pages to get the correct SMTP settings. A restart of Home Assistant is required to pick up the configuration changes.
{% configuration %}
name:
Expand Down Expand Up @@ -86,7 +86,28 @@ verify_ssl:

### Usage

To use the SMTP notification, refer to it in an automation or script like in this example:
A notify integration will be created using the name without spaces. In the above example, it will be called `notify.NOTIFIER_NAME`. To use the SMTP notification, refer to it in an automation or script like in this example:

```yaml
- alias: "Send E-Mail Every Morning"
description: ""
trigger:
- platform: time
at: "08:00:00"
condition: []
action:
- service: notify.NOTIFIER_NAME
data:
title: "Good Morning"
message: "Rise and shine"
target:
- "[email protected]"
mode: single
```

The optional `target` field is used to specify recipient(s) for this specific service call. When `target` field is not used, this message will be sent to default recipient(s), in this example, [email protected].

Another example attaching images stored locally in a script:

```yaml
burglar:
Expand All @@ -107,8 +128,6 @@ burglar:
- /home/pi/snapshot2.jpg
```

The optional `target` field is used to specify recipient(s) for this specific service call. When `target` field is not used, this message will be sent to default recipient(s), in this example, [email protected].

The optional `html` field makes a custom text/HTML multi-part message, allowing total freedom for sending rich HTML emails by defining the HTML content. In them, if you need to include images, you can pass both arguments (`html` and `images`). The images will be attached with the basename of the images, so they can be included in the html page with `src="cid:image_name.ext"`.

The optional `images` field adds image attachments to the email. If `html` is defined, the images need to be added to the message in-line as described above (and as shown in the example below). If `html` is not defined, images will be added as separate attachments.
Expand Down

0 comments on commit d74e245

Please sign in to comment.