Receipt HTML template: a minimal HTML email for order confirmations, built with table-based layout and inline styles
Receipt HTML template with table-based layout, inline styles, and dark mode support. Includes a plain-text fallback, a schema check that fails the build on field renames, and a curl snippet that sends the receipt through the send.io POST /emails endpoint with an idempotency key.
On this page
TL;DR: A production receipt email needs a table-based HTML layout with inline styles, a plain-text fallback that mirrors the line items exactly, and a schema contract that breaks the build when a field rename breaks the receipt. The trade-off is verbosity: tables and inline styles are harder to maintain than modern CSS, but Gmail can strip <style> blocks and Outlook desktop honors only a small subset of style rules. Required fields: order ID, order date, line items with quantity and unit price, tax, total, refund policy. Optional fields: customer name, payment method.Your receipt email looks perfect in Gmail and broken in Outlook. The fix isn't a design system. It's a table-based layout with inline styles. Most receipt email tutorials show a pretty template and skip the parts that break in production: Outlook's table rendering, dark mode color inversion, plain-text fallback drift, and schema contract violations that turn field renames into silent bugs.
Production-ready HTML receipt template code
A production receipt email typically pairs an HTML part with a plain-text fallback, sent together as a multipart message through send.io's POST /emails endpoint. The template below is a complete, copy-pasteable HTML receipt that renders reliably when built with table-based layout and inline styles, as used in the template below.
Before vs. after: bloated HTML vs. clean table-based markup
Visual editors generate HTML with redundant inline styles and nested tables that produce unreadable diffs in version control. The following comparison shows a typical visual-editor output versus the clean table-based approach:
Bloated visual-editor output (avoid this):
<div class="container" style="width:600px;margin:0 auto;">
<div class="header" style="background:#2563eb;padding:30px;">
<h1 style="color:#fff;font-size:24px;">Order Confirmation</h1>
</div>
</div>
Clean table-based markup (use this):
<table role="presentation" width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff;">
<tr>
<td style="background-color: #2563eb; padding: 30px;">
<h1 style="margin: 0; color: #ffffff; font-size: 24px;">Order Confirmation</h1>
</td>
</tr>
</table>
The table-based approach renders correctly in Outlook, which ignores <div> margin and width rules. Tables are a compatibility workaround rather than a design preference because email clients reject modern CSS layouts such as flexbox and grid. Hand-written markup also produces shorter, more readable diffs in version control than generated visual-editor output, though this depends on how disciplined the template stays.
Full source code for email receipts
The following template uses a table-based layout with inline styles on every element. This structure is required because<style> Gmail strips <style> blocks and Outlook desktop honors only a small subset of style rules, so table layouts with inline styles render most reliably across clients.
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Order Receipt</title>
<style>
@media (prefers-color-scheme: dark) {
.receipt-container { background-color: #1a1a1a !important; }
.receipt-body { color: #e0e0e0 !important; }
.receipt-table td { color: #e0e0e0 !important; border-color: #404040 !important; }
}
</style>
</head>
<body style="margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #f5f5f5;">
<table role="presentation" class="receipt-container" width="600" cellpadding="0" cellspacing="0" style="margin: 20px auto; background-color: #ffffff; border-radius: 8px;">
<tr>
<td style="background-color: #2563eb; padding: 30px; text-align: center;">
<h1 style="margin: 0; color: #ffffff; font-size: 24px;">Order Confirmation</h1>
</td>
</tr>
<tr>
<td class="receipt-body" style="padding: 30px;">
<p style="margin: 0 0 20px 0; color: #333333; font-size: 16px;">Thank you for your order:</p>
<table width="100%" cellpadding="0" cellspacing="0" style="margin-bottom: 20px;">
<tr>
<td style="padding: 8px 0; color: #666666; font-size: 14px;"><strong>Order ID:</strong></td>
<td style="padding: 8px 0; color: #333333; font-size: 14px; text-align: right;">{{order_id}}</td>
</tr>
<tr>
<td style="padding: 8px 0; color: #666666; font-size: 14px;"><strong>Order Date:</strong></td>
<td style="padding: 8px 0; color: #333333; font-size: 14px; text-align: right;">{{order_date}}</td>
</tr>
</table>
<table class="receipt-table" width="100%" cellpadding="0" cellspacing="0" style="border-collapse: collapse;">
<thead>
<tr>
<th style="background-color: #f8f9fa; padding: 12px; text-align: left; font-size: 14px; border-bottom: 2px solid #dee2e6;">Item</th>
<th style="background-color: #f8f9fa; padding: 12px; text-align: center; font-size: 14px; border-bottom: 2px solid #dee2e6;">Qty</th>
<th style="background-color: #f8f9fa; padding: 12px; text-align: right; font-size: 14px; border-bottom: 2px solid #dee2e6;">Total</th>
</tr>
</thead>
<tbody>
{{#each line_items}}
<tr>
<td style="padding: 12px; font-size: 14px; border-bottom: 1px solid #dee2e6; word-break: break-word; overflow-wrap: anywhere;">{{product_name}}</td>
<td style="padding: 12px; text-align: center; font-size: 14px; border-bottom: 1px solid #dee2e6;">{{quantity}}</td>
<td style="padding: 12px; text-align: right; font-size: 14px; border-bottom: 1px solid #dee2e6;">{{line_total}}</td>
</tr>
{{/each}}
</tbody>
</table>
<table width="100%" cellpadding="0" cellspacing="0" style="margin-top: 20px;">
<tr>
<td style="padding: 8px 0; text-align: right;"><strong>Subtotal:</strong></td>
<td style="padding: 8px 0; text-align: right; width: 100px;">{{subtotal}}</td>
</tr>
<tr>
<td style="padding: 8px 0; text-align: right;"><strong>Tax:</strong></td>
<td style="padding: 8px 0; text-align: right;">{{tax}}</td>
</tr>
<tr>
<td style="padding: 12px 0; text-align: right; font-size: 16px; font-weight: 600; border-top: 2px solid #dee2e6;"><strong>Total:</strong></td>
<td style="padding: 12px 0; text-align: right; font-size: 16px; font-weight: 600; border-top: 2px solid #dee2e6;">{{total}}</td>
</tr>
</table>
<div style="margin-top: 30px; padding: 15px; background-color: #f8f9fa; border-left: 4px solid #2563eb;">
<p style="margin: 0; font-size: 13px;"><strong>Refund Policy:</strong> {{refund_policy}}</p>
</div>
</td>
</tr>
</table>
</body>
</html>
Mandatory fields for receipt payloads
A valid receipt email requires specific fields to function correctly for customer support and accounting. Stripe's receipt documentation specifies that compliance requires contact information on every receipt: legal business name, customer support address, customer support email, and privacy policy URL. Itemization isn't part of that compliance list. Stripe treats an itemized record of a completed purchase as a separate paid-invoice feature, so the line items in this template are a design choice for order confirmations, not a Stripe compliance requirement.
The following table lists the required and optional fields for a receipt email:
Field | Requirement | Description |
|---|---|---|
Order ID | Required | Unique identifier for customer support lookups |
Order date | Required | Transaction date for accounting and support |
Line items | Required | Product name, quantity, unit price, line total |
Subtotal | Required | Sum of all line item totals before tax |
Tax | Required | Tax amount calculated from subtotal |
Total | Required | Final amount charged to the customer |
Refund policy | Required | Terms for returns and refunds |
Customer name | Optional | Personalizes the receipt |
Payment method | Optional | Last four digits of card or payment type |
Required fields must be present in both HTML and plain-text versions. The plain-text format must match the HTML line items exactly to avoid drift.
Stable table markup for receipt emails
Email clients strip or ignore external CSS and <style> blocks, so table-based layouts with inline styles are the only reliable way to render receipt emails across the major email clients.
The table structure uses fixed widths because Outlook requires fixed-width tables, and responsive design breaks in Outlook desktop. The template uses a 600-pixel container width and renders reliably when built with table-based layout and inline styles.
Styling emails with inline CSS and dark mode
Inline styles are the most widely supported CSS form across email clients. External stylesheets and <style> blocks can be stripped by Gmail, and Outlook desktop honors only a small subset of style rules, so every element in the template includes inline styles.
Avoiding CSS dependency issues
Gmail can strip style blocks, and Outlook often doesn't support background images. The template applies inline styles to every element, including the container, header, body, table cells, and text elements.
The template includes a <style> block only for the dark mode media query, which is the only exception to the inline-styles-only rule. This media query is supported by Apple Mail, iOS Mail, and Gmail's iOS and Android apps, but ignored by Gmail's desktop web client and Outlook, which require inline styles only.
Applying dark mode CSS fallbacks
Dark mode support varies across email clients. Apple Mail and iOS Mail respect the @media (prefers-color-scheme: dark) query. Gmail's iOS and Android apps support media queries, but its desktop web client does not, so media query breakpoints only apply in mobile Gmail. The template includes a dark mode fallback in the <style> block that overrides colors for clients that support the media query.
The dark mode fallback changes the background to dark gray (#1a1a1a) and the text to light gray (#e0e0e0), which keeps the receipt readable in clients that support the media query. Clients that ignore the query show the default light colors, so check both renderings in Litmus or Email on Acid before deploying.
Tested email client support matrix
The following table shows email client support for inline styles, dark mode media queries, and table-based layouts:
Email Client | Inline Styles | Inline Styles | Table-Based Layout |
|---|---|---|---|
Gmail (desktop web) | Supported | Not supported | Supported |
Apple Mail | Supported | Supported | Supported |
Outlook Desktop | Supported | Not supported | Supported (fixed width required) |
Outlook Web | Supported | Not supported | Supported |
Yahoo Mail | Supported | Not supported | Supported |
iOS Mail | Supported | Supported | Supported |
Android Gmail App | Supported | Supported | Supported |
Apple Mail and iOS Mail support the dark mode media query, so check the fallback in those clients first. Gmail's desktop web client doesn't support the query and requires inline styles only.
Decision matrix: email HTML vs. PDF receipts
Some teams generate PDF receipts instead of HTML emails. The following table compares the two approaches for order confirmations:
Factor | HTML Email (Maizzle/Tailwind) | PDF (Puppeteer/Headless Chrome) |
|---|---|---|
Rendering reliability | Table-based HTML works across major clients | PDF renders identically everywhere |
Maintenance cost | Template edits ship with the next deploy, and HTML needs no compilation step, though a CI/CD pipeline can still validate and deploy it | Changes require regenerating PDFs in the rendering pipeline, which can also run through CI/CD |
Accessibility | Screen readers parse HTML natively | PDF accessibility requires manual tagging |
File size | Under 102 KB (75 KB ideal) to avoid Gmail clipping | 50–200 KB PDF attachment |
Based on the trade-offs in the table above, use HTML email templates for transactional receipts because they render inline without requiring a download. PDF receipts are a better fit for invoices that need to be printed or archived, though the right choice depends on your own requirements.
Structuring plain-text order confirmations
The plain-text alternative is a deliverability and accessibility requirement that must mirror the HTML line items exactly. Email clients that don't support HTML render the plain-text version, so the two versions must stay consistent.
Fallback logic for text emails
The plain-text template uses fixed-width formatting to align the line items. The format must match the HTML version exactly to avoid drift. The template includes the same required fields: order ID, order date, line items, subtotal, tax, total, and refund policy.
ORDER CONFIRMATION
Order ID: {{order_id}}
Order Date: {{order_date}}
LINE ITEMS
----------
{{#each line_items}}
{{product_name}}
Qty: {{quantity}} Price: {{unit_price}} Total: {{line_total}}
{{/each}}
Subtotal: {{subtotal}}
Tax: {{tax}}
Total: {{total}}
REFUND POLICY
{{refund_policy}}
The plain-text version uses the same template variables as the HTML version, so a single data object populates both versions. Each line item is a product name on one line, then quantity, unit price, and line total on the next line, offset by a two-space indent. That indent is a template convention, not a documented standard, so keep the values identical to the HTML line items and adjust the spacing to suit your own template.
Configuring MIME types for email delivery
The email uses the multipart/alternative MIME type, which includes both HTML and plain-text versions. The client renders the version it supports. send.io accepts both versions in a single request when you include the html and text fields in the API payload.
Automating delivery via send.io API
The send.io API accepts both HTML and plain-text versions in one request and authenticates with a bearer API key. A single curl command sends the receipt.
Sending receipts with cURL
The following curl command sends the receipt through send.io's POST /emails endpoint:
curl -X POST https://api.send.io/emails \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-{{order_id}}" \
-d @receipt-payload.json
The Idempotency-Key value is derived from the order ID only, so every retry of the same order carries the same key. Don't append a timestamp such as $(date +%s): it generates a fresh key on each invocation, so a retried request never matches the original and the API can send a duplicate email.
The receipt-payload.json file contains the full HTML and plain-text versions. Store the template files separately and construct the JSON payload in your application code.
Setting up required API authentication
The Authorization: Bearer header includes your API key. You can create an API key in the send.io dashboard. Scoped API keys carry a permission list and can't grant access they don't hold, so a key scoped to sending can't perform actions outside that list.
The API key authenticates the request and identifies your account. The key should be stored as an environment variable, not hardcoded in your application.
Payload schema for order receipts
The JSON payload includes the following fields:
Field | Type | Required | Description |
|---|---|---|---|
| string | Yes | Recipient email address |
| string | Yes | Sender email address (must be on a verified domain) |
| string | Yes | Email subject line |
| string | Yes | HTML version of the receipt |
| string | Yes | Plain-text version of the receipt |
| HTTP header | No | Client-generated key to prevent duplicate sends |
The Idempotency-Key header prevents duplicate sends on retry. Idempotency keys make a repeated request return the first result, not a second email. If a retry sends the same key within 24 hours, the API returns the original response instead of sending a duplicate. The header is optional, and a request sent without it gets no deduplication protection, so a retried request can send a second email.
Test this template before production
Send this template through the send.io API using the documented test addresses for delivered and bounced outcomes before wiring it into your order service. The test addresses check delivery behavior, not rendering, so verify dark mode and layout in Litmus or Email on Acid.
How to maintain stable email schema contracts
Keeping the receipt template in version control next to the order schema turns field renames from silent production bugs into build failures. A field rename in the order schema breaks the receipt template at build time, not at runtime.
Syncing HTML receipts with schema definitions
The receipt template should live in the same repository as your order schema. A TypeScript interface defines the receipt payload structure:
interface ReceiptPayload {
order_id: string;
order_date: string;
customer_email: string;
line_items: Array<{
product_name: string;
quantity: number;
unit_price: string;
line_total: string;
}>;
subtotal: string;
tax: string;
total: string;
refund_policy: string;
support_email: string;
}
The template variables match the interface field names exactly, so the interface is the single source of truth for the payload structure.
Handling field name changes safely
A field rename in the order schema breaks the receipt template if the template references the old field name. A compile-time check validates the template against the schema:
function validateReceiptTemplate(template: string, schema: ReceiptPayload): boolean {
const templateVars = extractTemplateVars(template);
const schemaFields = Object.keys(schema);
return templateVars.every(field => schemaFields.includes(field));
}
This function extracts template variables from the HTML template and checks that each variable exists in the schema. Run it as a CI step so a mismatched variable blocks the deploy.
Type checking your HTML email payloads
A TypeScript type guard validates the receipt payload before sending:
function isValidReceiptPayload(payload: unknown): payload is ReceiptPayload {
return (
typeof payload === 'object' &&
payload !== null &&
'order_id' in payload &&
'order_date' in payload &&
'line_items' in payload &&
Array.isArray(payload.line_items) &&
payload.line_items.every(item =>
'product_name' in item &&
'quantity' in item &&
'unit_price' in item &&
'line_total' in item
) &&
'subtotal' in payload &&
'tax' in payload &&
'total' in payload &&
'refund_policy' in payload &&
'support_email' in payload
);
}
The type guard checks that all required fields are present before sending, so a malformed payload is rejected before it reaches the API.
Production-ready checklist for receipt emails
Before deploying a receipt template to production, verify the following:
- Data injection works: Replace all
{{template_vars}}with real order data using Handlebars, Jinja2, or your template engine of choice. - CI/CD pipeline integration: Add a test that sends a sample receipt on every deploy and validates the rendered output.
- Rendering verification: Test the template on Litmus or Email on Acid across Gmail, Outlook, Apple Mail, and iOS Mail.
- Edge case handling: Validate that the template handles long product names, including long unbroken strings with no spaces, multi-currency amounts, and refunded orders without breaking the layout.
Rendering required fields in the template
The required fields in the table above map to specific markup and calculations in the template. The sections below show the code for each one.
Required order ID and date fields
Order ID and date are required for customer support lookups and accounting reconciliation. The HTML markup for these fields is:
<tr>
<td style="padding: 8px 0; color: #666666; font-size: 14px;"><strong>Order ID:</strong></td>
<td style="padding: 8px 0; color: #333333; font-size: 14px; text-align: right;">{{order_id}}</td>
</tr>
The order ID should be a unique identifier that customer support can use to look up the order. Neither send.io's documentation nor Stripe's receipt documentation specifies a required date format for the order date. Many teams render it as a readable date, such as "November 10, 2026", rather than a raw timestamp. Whichever format you choose, use it consistently in both the HTML and plain-text versions.
Calculating line items, tax, and totals
Line item totals are calculated as quantity multiplied by unit price. The template variable {{line_total}} should be calculated before rendering:
const lineTotal = (item.quantity * parseFloat(item.unit_price)).toFixed(2);
The calculation should use the same currency and precision as the order schema. Tax is calculated from the taxable subtotal. For orders without discounts, tips, or service charges, the total is the subtotal plus tax. If your orders include any of those, apply discounts before calculating tax, add tips and service charges after, and show each as its own line so the receipt reconciles. For multi-currency receipts, a common general practice is to store the currency code as a separate field and format the amount with that code in both HTML and plain-text versions. send.io's documentation doesn't require this structure, so adapt it to your order schema.
Implementing refund terms in email
The refund policy must be in the receipt email because customers need to know the terms for returns and refunds. The HTML markup for the refund policy is:
<div style="margin-top: 30px; padding: 15px; background-color: #f8f9fa; border-left: 4px solid #2563eb;">
<p style="margin: 0; font-size: 13px;"><strong>Refund Policy:</strong> {{refund_policy}}</p>
</div>
The refund policy should be a clear, concise statement of the terms. The same policy must appear in the plain-text version.
Ensuring reliable layout across email providers
Email clients render HTML differently, so run the template through a rendering service such as Litmus or Email on Acid before deployment. These services render the template in real email clients, so you can check Gmail, Outlook, Apple Mail, Yahoo Mail, iOS Mail, and the Android Gmail app for client-specific rendering issues before the template reaches production.
Validating receipt data states
The template must handle edge cases: empty line items, zero quantity, negative totals, and refunded orders. Validation logic should reject invalid receipt data before sending:
function validateReceiptData(data: ReceiptPayload): boolean {
if (data.line_items.length === 0) return false;
if (data.line_items.some(item => item.quantity <= 0)) return false;
if (parseFloat(data.total) < 0) return false;
return true;
}
This validation catches invalid data before the receipt is sent. The validation converts total to a number because the template variables store currency amounts as strings with currency symbols.
Validating overflow for long product names
Long product names overflow fixed-width table cells. The template uses CSS word-break: break-word and overflow-wrap: anywhere on table cells to prevent overflow. The overflow-wrap CSS property sets whether the browser should insert line breaks within an otherwise unbreakable string.
The table cells include both properties to ensure long product names wrap correctly:
<td style="padding: 12px; font-size: 14px; border-bottom: 1px solid #dee2e6; word-break: break-word; overflow-wrap: anywhere;">{{product_name}}</td>
This prevents long product names from breaking the table layout.
Common pitfalls when building receipt templates
The following mistakes break receipt emails in production:
Visual editors destroy maintainability: Drag-and-drop email builders such as Mailchimp's editor and other WYSIWYG editors can generate bloated HTML with redundant inline styles, nested tables, and non-semantic markup. The output is impossible to maintain in version control. Write receipt templates by hand or use a code-based tool like Maizzle.
Standard web CSS fails in email clients: External stylesheets and <style> blocks work in browsers, but Gmail can strip them and Outlook desktop honors only a small subset of style rules. Every style rule must be inline on the element it affects.
Long product names overflow fixed-width cells: Product names with long unbroken strings can break table layouts in Outlook. Add word-break: break-word and overflow-wrap: anywhere to table cells that contain product names.
Tax calculations introduce rounding errors: Calculating tax as subtotal * tax_rate can produce rounding errors when the result has more than two decimal places. Round each line item total before summing to match the order schema's calculation.
Before wiring the template into your order service, send one test receipt through the POST /emails endpoint. send.io accepts the HTML and plain-text parts in a single POST /emails request, so one POST /emails call sends both versions, and you compare how each renders in the recipient mail client. Use one of its documented test addresses to check delivery behavior, then open the same receipt in Litmus or Email on Acid to check dark mode and long product names, since test addresses don't check rendering.
FAQs
What is the best receipt HTML template for developers?
A table-based template with inline styles, a dark-mode fallback, and a plain-text alternative. The template renders reliably when built with table-based layout and inline styles, as used in the template above, but it hasn't been tested in any specific number of clients, so run it through Litmus or Email on Acid before deploying to check how it renders in the clients your recipients use.
Why use table-based layouts for email receipts?
Email clients strip external CSS and <style> blocks. Table-based layouts with inline styles render consistently across Gmail, Outlook, Apple Mail, and Yahoo Mail.
How do you add custom branding to the template?
Replace the header background color and logo URL in the inline styles. Keep the table structure intact to preserve rendering reliability.
Can you use CSS classes instead of inline styles?
No. Gmail can strip <style> blocks, and Outlook desktop honors only a small subset of style rules. Inline styles on every element are the most reliable approach.
How do you handle multiple currencies in receipts?
A common general practice is to store the currency code as a separate field in the order schema and format the amount with that code in both HTML and plain-text versions. send.io's documentation doesn't require this structure, so adapt it to your order schema.
Key terms glossary
Dark mode fallback: A @media (prefers-color-scheme: dark) CSS rule that overrides colors for dark mode clients.
Idempotency key: A client-generated header that prevents duplicate sends on retry. send.io stores it for 24 hours.
Inline CSS: CSS applied directly to an HTML element via the style attribute. Required for email clients that strip <style> blocks.
Multipart/alternative: A MIME type that includes both HTML and plain-text versions of an email. The client renders the version it supports.
Schema contract: A compile-time check that validates the receipt template against the order schema. Catches field renames at build time.
Table-based layout: HTML <table> elements used for layout instead of CSS flexbox or grid. The only reliable layout method for email clients.