Why both HTML and text matter
The BosonMail SDK acceptstext and html together in the same sendEmail call. Providing both improves compatibility across clients and accessibility tools. The SDK does not include a template engine: you build the markup in your own application code.
Define the email data shape
Start with a TypeScript interface so the renderer is type-safe and reusable.types.ts
Escape helper
User-supplied values must be escaped before they reach HTML or text output.escape.ts
Render HTML with inline styles
Build a narrow HTML table layout. Keep styles inline because many clients ignore<style> blocks in <head>.
render-html.ts
Render plain text
Produce a matching plain-text version for clients that do not render HTML.render-text.ts
Send the email
Wire the renderer into a reusable sender function.send-order-confirmation.ts
Usage example
example.ts
Testing tips across clients
Keep HTML size reasonable
Keep HTML size reasonable
Large HTML bodies increase rejection risk and slow rendering. Aim for under 100 KB of markup. Move heavy images to attachments or host them externally.
Test in multiple clients
Test in multiple clients
Use services such as Litmus or Email on Acid to preview how your table-based layout renders in Outlook, Gmail, Apple Mail, and mobile clients. Inline styles are the safest cross-client approach.
Avoid external CSS and web fonts
Avoid external CSS and web fonts
Many email clients strip
<style> blocks and ignore @font-face. Use system font stacks and inline style attributes on every element that needs styling.Validate before sending
Validate before sending
Run your HTML through a validator or linter to catch unclosed tags and broken tables. A malformed email may still be accepted by the API but render poorly for the recipient.
Next steps
Sending with attachments
Attach PDF invoices and CSV exports to your order confirmations.
Multiple recipients
Send the same confirmation to billing and shipping contacts using CC and BCC.
Monitoring delivery
Track whether the confirmation was delivered, bounced, or deferred.
SDK reference: HTML emails
Read the concise SDK reference for the
html and text body options.