Inline Images
What are inline images?
Inline images (also called embedded images) are images that appear directly within your email content, rather than as attachments. They're referenced using a special cid: (Content-ID) URL scheme in your HTML, making them ideal for:
- Email signatures: Company logos and branding
- Transactional emails: Product images, receipts, invoices
- Branded templates: Headers, footers, and design elements
- Rich content: Diagrams, charts, and visual elements
Inline images are embedded in the email itself, so recipients see them immediately without downloading attachments—even with images disabled in some email clients.
How inline images work
- Attach an image with a unique Content-ID
- Reference the image in your HTML using
cid:your-content-id - Email clients display the image inline when rendering the email
The Content-ID acts as a unique identifier linking your HTML image references to the actual image data.
Sending inline images via API
Basic example
The content field must be base64-encoded image data. Most programming languages provide built-in functions for base64 encoding files. Common image MIME types (PNG, JPG, GIF, WebP) are automatically detected from the file content.
Multiple inline images
You can embed multiple images by using different Content-IDs for each:
The total email size—including all inline images, attachments, HTML, and headers—must not exceed 25MB. See Limitations for details.
Sending inline images via SMTP
When using SMTP, the email library handles Content-ID headers automatically for inline attachments.
Nodemailer (Node.js)
Code
PHPMailer (PHP)
Code
Python (smtplib)
Code
Content-ID format requirements
Content-IDs must follow these rules:
- Allowed characters: Letters (a-z, A-Z), numbers (0-9), dots (.), underscores (_), hyphens (-), and at-signs (@)
- Pattern: Must match
^[a-zA-Z0-9._@-]+$ - Maximum length: 255 characters
- Automatic suffix: If your Content-ID doesn't include
@, Lettermint automatically appends@lmto ensure RFC compliance
Valid Content-ID examples
- ✅
logo - ✅
company-logo - ✅
header_image - ✅
product.image.v2 - ✅
banner@example.com - ✅
invoice-2024-01
Invalid Content-ID examples
- ❌
logo image(spaces not allowed) - ❌
product#123(# symbol not allowed) - ❌
header!image(! symbol not allowed) - ❌
logo/banner(/ symbol not allowed)
Use descriptive, semantic Content-IDs like company-logo or product-image instead of generic names like image1 or img. This makes your email templates more maintainable.
Troubleshooting
Image not displaying
Check your Content-ID reference
- Ensure your HTML uses
cid:your-content-id(note thecid:prefix) - Verify the Content-ID in your attachment matches the HTML reference exactly (case-sensitive)
- Don't include angle brackets (
<>) in your Content-ID when using the API
Verify base64 encoding
- The
contentfield must contain valid base64-encoded image data - Test your base64 string with an online decoder to ensure it's valid
Check HTML syntax
Code
Image appears as attachment
If your inline image also appears as a downloadable attachment:
- Ensure you're setting
content_idin your API request - For SMTP, verify your email library supports inline attachments (check library-specific documentation)
Content-ID validation errors
If you receive validation errors:
- Remove special characters except dots, underscores, hyphens, and @
- Keep Content-IDs under 255 characters
- Use only alphanumeric characters if unsure
Best practices
- Use descriptive Content-IDs: Choose meaningful names that describe the image's purpose
- Optimize image sizes: Keep images small to reduce email size and improve deliverability
- Provide alt text: Always include
altattributes for accessibility and when images are blocked - Test across email clients: Different email clients handle inline images differently—test thoroughly
- Consider fallbacks: Some email clients block images by default—design emails that work without them
Related
- Limitations — Email size limits (25MB) and blocked file types
- Tags — Organize and categorize your emails
- Webhook events — Track delivery and engagement for emails with inline images