Agent Wranglers

EML-8Recommended

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. Send the files you still attach as Avoid risky attachments says.

Examples

JavaScript example

const htmlBytes = Buffer.byteLength(renderedHtml, 'utf8');
if (htmlBytes > 100 * 1024) throw new Error(`HTML part is ${htmlBytes} bytes, keep it under 100 KB`);

Python example

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: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/email/message-basics/message-size">Agent Wranglers email playbook</a>. In code you write, add a comment next to it with the same link.