Skip to main content

The short answer

Pass an html field to messages.send() alongside the plain text fallback. Email clients that support HTML will render the rich version; older clients and screen readers fall back to plain text. Always send both.

Why plain text is not enough

When your agent sends a support reply, a sales follow-up, or a weekly digest, plain text looks like spam. Recipients expect formatted emails — bold text for emphasis, links that are clickable, tables for data, and a visual structure that signals “this is a real business email.” Plain text also loses information. A bulleted action list becomes a wall of dashes. A table of invoice line items becomes unreadable. HTML lets your agent communicate with the same fidelity a human would.

Sending HTML with the SDK

Both the TypeScript and Python SDKs accept html and text on messages.send(). Always provide both — text is the accessibility fallback and is used by spam filters to validate content consistency.

Inline styles are mandatory

Email clients strip <style> tags. Gmail removes them entirely. Outlook ignores them. Yahoo strips them on mobile. This is the single biggest gotcha in HTML email development. Every CSS property must be applied inline via the style attribute:
Other rules that apply to HTML email but not to the web:

Building a template system

For agents that send recurring emails (digest reports, status updates, ticket resolutions), build a template function that your agent calls before sending. This keeps HTML out of your LLM prompts and ensures visual consistency.

Responsive design basics

Most emails are read on mobile. Keep layouts simple and they will naturally adapt:
  1. Set a max-width of 600px on your outer container. This is the universal safe width for email.
  2. Use a single-column layout. Multi-column layouts break on mobile Outlook and small screens.
  3. Set font sizes to at least 14px. Anything smaller gets auto-zoomed on iOS, breaking your layout.
  4. Use percentage widths for tables (width: 100%) so they scale down on narrow screens.
  5. Test with real inboxes. Send a test email to Gmail, Outlook, and Apple Mail before going live.
Commune’s messages.send() does not modify your HTML. What you pass in the html field is exactly what gets delivered. If you want CSS inlining or responsive transformations, use a library like juice (Node.js) or premailer (Python) before sending.

Messages

Full API reference for sending emails including HTML, attachments, and threading.

Email Signatures for Agents

Append consistent HTML signatures to every agent email.

Attaching Files

Upload and attach files to outbound agent emails.
Last modified on March 19, 2026