What is MIME Types in Email?

MIME (Multipurpose Internet Mail Extensions) extends email beyond plain text by defining content types and encoding schemes. MIME enables HTML emails, file attachments, and multipart messages that contain both text and HTML versions. Understanding MIME is essential for building and testing rich email experiences.

Common Email MIME Types

Content Types

  • text/plain: Plain text email
  • text/html: HTML formatted email
  • multipart/alternative: Contains both text and HTML versions
  • multipart/mixed: Email with attachments

Attachment Types

  • application/pdf: PDF documents
  • image/png, image/jpeg: Images
  • application/octet-stream: Binary files

Email Structure `` multipart/mixed ├── multipart/alternative │ ├── text/plain (fallback) │ └── text/html (rich content) └── application/pdf (attachment)

Testing MIME Content

When testing emails, verify both text and HTML versions:

test('email has both plain text and HTML versions', async () => {

// Verify plain text version exists expect(email.textContent).toBeDefined(); expect(email.textContent).toContain('Welcome');

// Verify HTML version exists expect(email.htmlContent).toBeDefined(); expect(email.htmlContent).toContain('<h1>Welcome</h1>');

// Verify they contain equivalent content const textLinks = email.textContent.match(/https?:\/\/[^\s]+/g); const htmlLinks = email.htmlContent.match(/href="([^"]+)"/g); expect(textLinks?.length).toBeGreaterThan(0); }); ```

Always provide a text fallback—some email clients don't render HTML.

Related Use Cases

Try mime types in email with plop.email

Get started with reliable email testing in minutes.