Receive file attachments via email

Extract, store, and process email attachments automatically. Get structured metadata and download URLs.

The Problem

  • Parsing MIME attachments from raw email is complex and error-prone
  • Attachment encoding varies across email clients and breaks your parser
  • Storing attachments requires setting up file storage infrastructure
  • Large attachments can timeout your email processing pipeline
  • Inline images and regular attachments are mixed together confusingly

Why Existing Solutions Fall Short

MIME parsing libraries require deep knowledge of email internals

Base64 decoding and content-type detection is tedious to implement

Self-hosted storage adds infrastructure burden and security concerns

Email forwarding strips or corrupts attachments unpredictably

You shouldn't have to build this yourself.

How Mailhooks Solves This

Automatic Extraction

Attachments are extracted and stored automatically. No parsing required.

Secure Storage

Files are stored securely and delivered via signed download URLs.

Rich Metadata

Get filename, content type, size, and checksum for every attachment.

Inline vs Attached

Clearly distinguish between inline images and file attachments.

How It Works

1

Email with files

User sends an email with attachments to your inbox.

2

Auto extraction

Mailhooks parses and stores all attachments.

3

Webhook fires

Your endpoint receives metadata and download URLs.

4

Download files

Fetch attachments using the signed URLs.

5

Process

Handle files in your application as needed.

Code Example

Attachments are extracted and delivered with secure download URLs.

Webhook Payload

{
  "id": "msg_attach789",
  "from": "[email protected]",
  "to": "[email protected]",
  "subject": "Documents for review",
  "text": "Please see attached files.",
  "attachments": [
    {
      "filename": "report.pdf",
      "contentType": "application/pdf",
      "size": 245678,
      "checksum": "sha256:abc123...",
      "url": "https://files.mailhooks.dev/...",
      "inline": false
    },
    {
      "filename": "chart.png",
      "contentType": "image/png",
      "size": 45678,
      "checksum": "sha256:def456...",
      "url": "https://files.mailhooks.dev/...",
      "inline": true,
      "contentId": "chart-001"
    }
  ]
}

Handler Code

// Process email attachments
app.post('/webhooks/email', async (req, res) => {
  const { from, subject, attachments } = req.body;

  for (const attachment of attachments) {
    // Skip inline images if needed
    if (attachment.inline) continue;

    console.log(`Processing: ${attachment.filename}`);
    console.log(`Size: ${attachment.size} bytes`);
    console.log(`Type: ${attachment.contentType}`);

    // Download the attachment
    const response = await fetch(attachment.url);
    const buffer = await response.arrayBuffer();

    // Save to your storage, process, etc.
    await saveToS3(attachment.filename, buffer);
  }

  res.status(200).send('OK');
});

Frequently Asked Questions

Every inbox can be configured with sender filtering rules. You can whitelist specific domains or email addresses, or use our webhook to implement your own spam filtering logic. Emails that don't match your rules are automatically rejected.

Webhooks are typically delivered within 100-500ms of email receipt. We process emails in real-time with no polling delays. For high-availability applications, we also offer webhook retries with exponential backoff.

Mailhooks is built specifically for inbound email. We offer simpler setup (no DNS changes required for testing), better attachment handling with direct download URLs, and a developer-first API for fetching emails programmatically—perfect for E2E testing.

Yes! You can connect your own domain with simple DNS configuration. We also provide free subdomains on inbox.mailhooks.dev for testing and development.

We automatically retry failed webhooks with exponential backoff for up to 24 hours. You can also use our API to fetch any missed emails. All emails are stored and accessible via the dashboard.

Get Started in 3 Steps

Takes ~2 minutes — no email infrastructure required.

1

Create a Mailhooks account

Sign up for free in seconds.

2

Create an inbox

Get a unique email address for your use case.

3

Add your webhook URL

Point to your endpoint and start receiving emails.

Start receiving email attachments in minutes