html field in SendEmailBody. You can send HTML-only, text-only, or both together. When you provide both, the API can present a multipart alternative that improves compatibility across email clients.
The html field
string
HTML content for the email body. Must be a non-empty string after trimming. Either
text or html (or both) is required.Why include both text and HTML
Email clients handle HTML differently. Some strip styles, others block external images, and a minority still prefer plain text. Providing bothtext and html gives the receiving server and client the option to display the most appropriate version.
Validation
The SDK enforces two rules for content fields:- If
textorhtmlis present, it must be a string:'text' and 'html' must be strings - At least one must be non-empty after trimming:
Email must contain text or HTML content
Practical HTML tips
Inline styles over external CSS
Most email clients ignore<style> blocks in the <head>. Use inline style attributes for reliable rendering.
Tables for layout
CSS Grid and Flexbox have limited support in email clients. Use HTML tables for complex layouts.Absolute image URLs
Always use fullhttps:// URLs for images. Relative paths and CID references are not supported by the SDK.
Escape user input to prevent HTML injection
If you interpolate user-provided data into HTML, escape it first. A simple helper:lib/escape-html.ts
Full example
send-html.ts
Sending emails
Full sendEmail reference with parameters and validation rules.
Attachments
How to attach files to HTML and text emails.
Guides: HTML emails
Step-by-step guide for building rich email templates.
Error handling
How to handle validation and API errors.