# What Happens When Envoke Sends

The HTML stored in Envoke is not exactly the HTML your recipients receive. When each email is sent, Envoke personalises it, adds tracking and, if needed, a footer, and generates a plain-text version. This page lists every change, in order, so you can tell which differences in a received email come from Envoke.

---

## Step by Step

For messages created in Envoke or through the [Messages API](https://envoke-developers.pages.dev/v2/messages/fields/), each email goes through these steps. Send API emails differ; see [Send API Differences](#send-api-differences).

| Step | What happens |
|---|---|
| 1. Whitespace | Every run of two or more whitespace characters (spaces, tabs, line breaks) is replaced by a single space, everywhere in the document. Text that relies on `<pre>` or `white-space: pre` to keep its spacing or line breaks loses them; use `<br>` and `&nbsp;` instead. |
| 2. Language | For a message whose language is French, every `lang="en"` and `xml:lang="en"` in the document becomes `lang="fr"` and `xml:lang="fr"`. For other languages, nothing changes. Set the message's language in Envoke rather than in the HTML: the drag-and-drop editor writes `lang="en"` on every save. |
| 3. Consent banner | If your account uses it, the consent banner is inserted after the opening `<body>` tag (see [The Consent Banner](https://envoke-developers.pages.dev/email-html/unsubscribe-and-footer/#the-consent-banner)). |
| 4. Title | `<title>{@msg-subject}</title>`, written exactly like this, gets the message's subject. |
| 5. Test note | For test sends with a note, the note is inserted above the first section (see [Test Sends](#test-sends)). |
| 6. Merge tags | Message, account, and preference tags are filled in for the contact (see [Merge Tags and Conditionals](https://envoke-developers.pages.dev/email-html/merge-tags/)). |
| 7. Links | The whole document is parsed and written out again, so markup that is not well formed can come out repaired differently than a browser would show it. Then, if UTM tagging is on for the message (the Messages API's [`utm_tag_links`](https://envoke-developers.pages.dev/v2/messages/fields/#utm_tag_links)), UTM parameters are added to each link whose `href` starts with `http://` or `https://`; and if click tracking is on, each link whose `href` starts with `http://`, `https://`, or a merge tag is replaced by a tracking link that redirects to it. `mailto:` links, `#` anchors, and links to image or CSS files are left alone. |
| 8. Merge tags | Custom fields and contact fields are filled in. |
| 9. Open tracking | A 1×1-pixel tracking image is added at the end of the email, except on test sends. |
| 10. Footer | If the HTML has no `{@pref-0}`, Envoke's default footer is added below your content (see [Envoke's Default Footer](https://envoke-developers.pages.dev/email-html/unsubscribe-and-footer/#envokes-default-footer)); otherwise, if your account shows the Envoke logo, a "Sent by" line and the logo are added. |
| 11. Plain text | The plain-text version of the email is generated from the final HTML (see [The Plain-Text Version](#the-plain-text-version)). |

Envoke does not otherwise minify, inline, or validate your HTML at send.

---

## Send API Differences

| Step | Send API emails |
|---|---|
| Personalisation | Each recipient's `replace` values are substituted first, before anything else is filled in. |
| Consent banner | Never added. |
| Merge tags | Only a few tags are filled in unless `enable_merge_fields` is on, and fewer contact fields are available (see [Send API Messages](https://envoke-developers.pages.dev/email-html/merge-tags/#send-api-messages)). |
| Links | UTM parameters are never added. The document is parsed and links are replaced by tracking links only when `track_recipient_activity` is on. |
| Open tracking | The tracking image is added only when `track_recipient_activity` is on. |
| Footer | Added when the HTML, before `replace`, has no `{@pref-0}`. |

See the [Send API fields](https://envoke-developers.pages.dev/v1/send/fields/#tracking-and-merge-fields) for the settings.

---

## Test Sends

A test email sent from Envoke differs from the real send in a few ways:

- The subject starts with `Test message from Envoke:` (in French for a French-speaking test contact).
- Links are not replaced by tracking links, and no open-tracking image is added.
- If you add a note to the test, it appears above the first section of the email. HTML with no sections gets no note.
- Merge tags are filled in from the test recipient's contact record.

Everything else, including the default footer, is the same as a real send.

---

## The Plain-Text Version

Every email is sent with a plain-text version, which Envoke generates from the final HTML after all the steps above. You cannot supply your own. If the generated text is shorter than 10 characters, it is replaced by a short message with a link to view the email online.

---

*Full reference, OpenAPI description, and Postman collection: [developers.envoke.com](https://developers.envoke.com).*
