Search code examples
htmlemailescapinghtml-emailmailmerge

Escaping HTML Escape Characters


I'm writing an email, and I want to include some custom HTML formatting like:

<p>Hello Friend</p><br><br> 

If I write the above directly in the email body, the email program will automatically escape out of characters like <, >, and &. resulting in the following:

&lt;p&gt;Hello Friend&lt;/p&gt;&lt;br&gt;&lt;br&gt;

Is there a way to avoid or reverse this escaping?

The problem is also occurring with a Mail Merge type software called GovDelivery. I want to put HTML inside their "macros" but GovDelivery automatically escapes out of the characters making it impossible to have custom formats per email.


Solution

  • The email provider does this to prevent against Cross Site Scripting (XSS) attacks and is most likely intentional behavior.

    As a solution, most services that disable this behavior use Markdown. That may result in similar behavior to what you want.