How can i format message body of smtp?

I’d like to send a long message via smtp, how can I format the message into multiple lines? “\r\n” does not work.

Are you using the SMTP component? It should be trivial if you use HTML, and I suspect (but haven’t tried) that the same approach will work for the plain text body:

    data_template:
        message: >
          This is your multi-line message
          You just can't have a blank line

        data:
          images:
            - /home/pi/snapshot1.jpg
            - /home/pi/snapshot2.jpg

When using message: > the first blank line ends the message.

@Tinkerer. Are you able to send images like shown above using the SMTP component?

Sorry for the off topic.

I don’t use the SMTP component

Hi there,
I’m sending Mails with Image and HTML with this script:

      - service: notify.gmail_smtp
        data_template:
          title: 'DWD Wetterwarnung!'
          message: ' '
          data:
            images:
              - warnungen_gemeinde_map_bay.png
            html: >
                <hr>
                {{ states.sensor.dwd_html.state }}

The file sensor reads a text file where the whole HTML is in one line and is generated from a python script.

1 Like

Hi,
how can I start new line in multiline message?? \n - does not work.

Also came here wondering how to insert a newline … \n or \\n etc?

update: I scoured around other threads and found that {{"\n"}} works for me. Example below will skip 2 lines.

action:
  - service: notify.SMTP
    data:
      title: Alert!
      message: {{ trigger.to_state.attributes.friendly_name }} alarm {{"\n\n"}}details: https://foo.com/whatever