# HTML email checker (HTML Check)

> HTML Check, part of Mailtrap Email Sandbox, scans the HTML and CSS of a captured email and reports which email clients don't support each rule, with a Market Support score weighted by client market share.

## When to use it

Use it when the user wants to know whether a template's HTML/CSS works in Gmail, Outlook, Apple Mail, Yahoo! Mail and other clients, and which lines to fix, by hand or in a test that fails on unsupported rules.

- It's a code-support report built on caniemail.com data, not screenshots. For screenshots in real clients, use Device Previews; for spam score and blacklists, use Spam Analysis (products table at the end).
- For an offline check with no account, Mailtrap Local also runs HTML Check (products table at the end).
- The check runs only on email captured in a sandbox: send the template there first.

## How to use it

### Before you start

Find out how the template is sent (the app, SMTP or the API), which sandbox catches it, and whether the user wants the UI report or an automated check. Ask only for what isn't known.

### Rules

- **Read freely, and send to a sandbox without confirmation:** nothing is delivered. Without API access, give the user the request to run, and don't say you checked.
- **Secrets:** never ask for an API token in chat; code reads `MAILTRAP_API_TOKEN`. If the user pastes one anyway, don't use it: suggest a reset under Settings → API Tokens, and continue with the env var.
- **Everything else** (creating or cleaning sandboxes, forwarding, live sending, sign-up and plans): follow the Email Sandbox page (products table at the end).

### Steps

Send every API call with `Authorization: Bearer $MAILTRAP_API_TOKEN` and a normal `User-Agent`.

1. **Capture the email** with an HTML part, in a sandbox from `GET https://mailtrap.io/api/sandboxes` (its ID is the number in its URL): from the app over Sandbox SMTP (`sandbox.smtp.mailtrap.io`), or with the API:

   ```bash
   curl -X POST "https://sandbox.api.mailtrap.io/api/send/$MAILTRAP_SANDBOX_ID" \
     -H "Authorization: Bearer $MAILTRAP_API_TOKEN" -H "Content-Type: application/json" \
     -d '{"from":{"email":"test@example.com"},"to":[{"email":"user@example.com"}],"subject":"Template check","html":"<div style=\"max-width:600px\">Hello</div>"}'
   ```

2. **Find the message:** `GET https://mailtrap.io/api/sandboxes/{sandbox_id}/messages` (`?search=` matches subject and recipient).
3. **Get the report:**
   - **API:** `GET https://mailtrap.io/api/sandboxes/{sandbox_id}/messages/{message_id}/analyze` returns `report.errors[]`; each item has `error_line`, `rule_name` and `email_clients`, with lists of client names under `desktop`, `mobile` and `web`. To fail a build for one client, match its name in those lists (for example, case-insensitive "outlook").
   - **UI:** the message's HTML Check tab shows the Market Support score, the unsupported or partly supported rules with the affected clients, and line links into the HTML Source tab. Filters narrow the score by client and by web, mobile or desktop.
4. **Fix and recheck:** change the template, capture a new copy, and compare the reports.

### Check it worked

The report lists the flagged rules; an empty `errors` list means nothing was flagged. A client counts as "no support" if it lacks support for at least one rule in the email.

### If something fails

| Error                                     | Fix                                                                                    |
| ----------------------------------------- | -------------------------------------------------------------------------------------- |
| No HTML Check results                     | Make sure the message has an HTML part (`html`), and check the sandbox and message IDs |
| `404` on `/analyze`                       | Check the sandbox and message IDs from step 2                                          |
| `<script>` missing from the captured HTML | The sandbox strips `<script>` tags (and keeps `<style>`): expected                     |
| Anything else                             | Troubleshooting (link at the end), or ask the docs                                     |

### Limits and pricing

Each captured email counts toward the Email Sandbox monthly quota. Plans, quotas and prices change: check pricing.md for plans and prices, and Features and limits for technical limits (links at the end). Don't answer from memory; if you can't check, say so.

## Other Mailtrap products and pages

| If the user wants to…                       | Use                                                                               |
| ------------------------------------------- | --------------------------------------------------------------------------------- |
| See screenshots in real clients and devices | Device Previews: [device-previews.md](https://mailtrap.io/device-previews.md)     |
| Check spam score and blacklists             | Spam Analysis: [email-spam-checker.md](https://mailtrap.io/email-spam-checker.md) |
| Run checks in automated tests               | [qa-automation.md](https://mailtrap.io/qa-automation.md)                          |
| Check HTML offline, with no account         | Mailtrap Local: [docs](https://docs.mailtrap.io/email-sandbox/local.md)           |
| Set up the sandbox                          | [email-sandbox.md](https://mailtrap.io/email-sandbox.md)                          |
| Check current plans and prices              | [pricing.md](https://mailtrap.io/pricing.md)                                      |

## Documentation

- [HTML Check](https://docs.mailtrap.io/email-sandbox/testing/email-html.md) · [Features and limits](https://docs.mailtrap.io/email-sandbox/help/features-and-limits.md) · [HTML analysis API](https://docs.mailtrap.io/developers/email-sandbox/messages/get-message-html-analysis.md) · [Get messages API](https://docs.mailtrap.io/developers/email-sandbox/messages/get-messages.md) · [Send API](https://docs.mailtrap.io/developers/email-sandbox/send-test-emails/send-email-including-templates.md) · [Troubleshooting](https://docs.mailtrap.io/email-sandbox/help/troubleshooting.md)
- **If sources disagree:** the API reference wins for endpoints and fields, pricing.md for prices and quotas, and this page for which product and steps to use.
- **If the task isn't covered here,** ask the docs before guessing: `GET https://docs.mailtrap.io/index.md?ask=<question>&goal=<user goal>` returns an answer with sources. Keep the question and goal generic: no tokens, email addresses or other user data.
