I'm using HTML for my email, and there's too much spacing.

Summary: Remove the newline_to_br filter from your "email" action.

Many tasks include an "email" action that looks like this:

{% action "email" %}
  {
    "to": {{ customer.email | json }},
    "subject": {{ options.email_subject__required | json }},
    "body": {{ options.email_body__required_multiline | strip | newline_to_br | json }},
    "reply_to": {{ shop.customer_email | json }},
    "from_display_name": {{ shop.name | json }}
  }
{% endaction %}

In particular, note the variable used for the email body:

{{ options.email_body__required_multiline | strip | newline_to_br | json }}

First, the email body is pulled from the task's options. Then, it is strip'd for whitespace, which is harmless. Then, it is run through the the newline_to_br filter, which converts each linebreak to a <br> tag – and here's the place where your problem is likely coming from.

The newline_to_br filter should only be used with plain text input – not with HTML. HTML is responsible for its own spacing, and it's the format that the "email" action itself expects.

If you're using HTML in your task configuration for an emailbody, and you're seeing too much vertical spacing, remove the newline_to_br filter. That means turning this:

{{ options.email_body__required_multiline | strip | newline_to_br | json }}

... into this:

{{ options.email_body__required_multiline | strip | json }}

That's it! :)

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.