Agent Wranglers

Message basics Required

Keep messages small

Keep the HTML part under 100 KB and the whole message under 5 MB. Link to large files instead of attaching them.

How to do it

Gmail clips HTML bodies larger than about 102 KB and hides the rest, including any unsubscribe link at the bottom. Many servers refuse messages above 10 to 25 MB, and base64 encoding adds about a third to attachments. Host images and large files, and link to them. Images do not count towards the clipping limit, but inline styles, tracking codes and long links do. Remove unused CSS and minify the HTML when you build it.

Example

const htmlBytes = Buffer.byteLength(renderedHtml, 'utf8');
if (htmlBytes > 100 * 1024) throw new Error(`HTML part is ${htmlBytes} bytes, keep it under 100 KB`);
html_bytes = len(rendered_html.encode("utf-8"))
if html_bytes > 100 * 1024:
    raise ValueError(f"HTML part is {html_bytes} bytes, keep it under 100 KB")

How to check

A script sends each template and fails when the encoded HTML part passes 100 KB or the whole message passes 5 MB. A test message in Gmail shows no "Message clipped" notice.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers email playbook: https://agentwranglers.se/playbook/email/message-basics/message-size.