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 specialcid:
(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
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.Multiple inline images
You can embed multiple images by using different Content-IDs for each:Sending inline images via SMTP
When using SMTP, the email library handles Content-ID headers automatically for inline attachments.Nodemailer (Node.js)
PHPMailer (PHP)
Python (smtplib)
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@lm
to 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
- The
content
field must contain valid base64-encoded image data - Test your base64 string with an online decoder to ensure it’s valid
Image appears as attachment
If your inline image also appears as a downloadable attachment:- Ensure you’re setting
content_id
in 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
alt
attributes 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
Summary
Inline images let you embed visual content directly in your emails using Content-ID references. By attaching images with acontent_id
and referencing them with cid:
in your HTML, you create rich, professional emails that display consistently across email clients.
For more examples and implementation details, check out our SDK documentation or explore the API reference.