Email parsing API - convert raw email to structured JSON

Email Parser API

Stop wrestling with MIME boundaries, base64 encoding, and charset issues. CloudMailin's email parser handles the complexity and delivers clean, structured JSON.

No regex, no libraries, no headaches - just parsed email data ready to use.

Raw Email

Return-Path: <from@example.com>
Received: by 10.52.90.229 with SMTP id bz5cs75582vdb;
 Mon, 16 Jan 2012 09:00:07 -0800
Received: by 10.216.131.153 with SMTP id
 m25mr5479776wei.9.1326733205283;
 Mon, 16 Jan 2012 09:00:05 -0800
Received: from mail-wi0-f170.google.com
 (mail-wi0-f170.google.com [209.85.212.170])
 by mx.google.com with ESMTPS id
 u74si9614172weq.62.2012.01.16.09.00.04
 (version=TLSv1/SSLv3 cipher=OTHER);
 Mon, 16 Jan 2012 09:00:04 -0800
Date: Mon, 16 Jan 2012 17:00:01 +0000
From: =?UTF-8?Q?Message_Sender?= <sender@example.com>
To: =?UTF-8?B?TWVzc2FnZSBSZWNpcGllbnQ=?= <to@example.co.uk>
Message-ID: <4F145791.8040802@example.com>
Subject: =?UTF-8?B?VGVzdCBTdWJqZWN0?=
MIME-Version: 1.0
Content-Type: multipart/alternative;
 boundary="------------090409040602000601080801"
Delivered-To: to@example.com
Received-SPF: neutral (google.com: 10.0.10.1 is neither
 permitted nor denied by best guess record for domain
 of from@example.com) client-ip=10.0.10.1;
Authentication-Results: mx.google.com; spf=neutral
 (google.com: 10.0.10.1 is neither permitted nor denied
 by best guess record for domain of from@example.com)
 smtp.mail=from@example.com
User-Agent: Postbox 3.0.2 (Macintosh/20111203)

--------------090409040602000601080801
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Test with HTML.
--------------090409040602000601080801
Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable

<html><head>=0A<meta http-equiv=3D"content-type"
content=3D"text/html; charset=3DISO-8859-1"></head>
<body=0A bgcolor=3D"#FFFFFF" text=3D"#000000">=0A
Test with <span style=3D"font-weight: bold;">HTML
</span>.<br>=0A</body>=0A</html>
--------------090409040602000601080801
Content-Type: text/plain; name="file.txt"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="file.txt"

dGVzdGZpbGU=
--------------090409040602000601080801
Content-Type: text/plain; charset="UTF-8"; name="menu.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="menu.txt"

Caf=C3=A9 menu
- Espresso =E2=82=AC3.50
- Latt=C3=A9 =E2=82=AC4.00
--------------090409040602000601080801--

Parsed JSON

// Example Email to HTTP POST in the JSON Format
{
  "headers": {
    "Return-Path": "from@example.com",
    "Received": [
      "by 10.52.90.229 with SMTP id bz5cs75582vdb; Mon, 16 Jan 2012 09:00:07 -0800",
      "by 10.216.131.153 with SMTP id m25mr5479776wei.9.1326733205283; Mon, 16 Jan 2012 09:00:05 -0800",
      "from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by mx.google.com with ESMTPS id u74si9614172weq.62.2012.01.16.09.00.04 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 16 Jan 2012 09:00:04 -0800"
    ],
    "Date": "Mon, 16 Jan 2012 17:00:01 +0000",
    "From": "Message Sender <sender@example.com>",
    "To": "Message Recipient<to@example.co.uk>",
    "Message-ID": "<4F145791.8040802@example.com>",
    "Subject": "Test Subject",
    "Mime-Version": "1.0",
    "Content-Type": "multipart/alternative; boundary=------------090409040602000601080801",
    "Delivered-To": "to@example.com",
    "Received-SPF": "neutral (google.com: 10.0.10.1 is neither permitted nor denied by best guess record for domain of from@example.com) client-ip=10.0.10.1;",
    "Authentication-Results": "mx.google.com; spf=neutral (google.com: 10.0.10.1 is neither permitted nor denied by best guess record for domain of from@example.com) smtp.mail=from@example.com",
    "User-Agent": "Postbox 3.0.2 (Macintosh/20111203)"
  },
  "envelope": {
    "to": "to@example.com",
    "from": "from@example.com",
    "helo_domain": "localhost",
    "remote_ip": "127.0.0.1",
    "recipients": [
      "to@example.com",
      "another@example.com"
    ],
    "spf": {
      "result": "pass",
      "domain": "example.com"
    }
  },
  "plain": "Test with HTML.",
  "html": "<html><head>\n<meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\"></head><body\n bgcolor=\"#FFFFFF\" text=\"#000000\">\nTest with <span style=\"font-weight: bold;\">HTML</span>.<br>\n</body>\n</html>",
  "reply_plain": "Message reply if found.",
  "attachments": [
    {
      "content": "dGVzdGZpbGU=",
      "file_name": "file.txt",
      "content_type": "text/plain",
      "size": 8,
      "disposition": "attachment"
    },
    {
      "content": "Q2Fmw6kgbWVudQotIEVzcHJlc3NvIOKCrDMuNTAKLSBMYXR0w6kg4oKsNC4wMA==",
      "file_name": "menu.txt",
      "content_type": "text/plain",
      "size": 42,
      "disposition": "attachment"
    }
  ]
}
  • No More MIME Headaches

    Stop decoding base64 and parsing multipart boundaries. We extract attachments automatically and deliver them ready to use.

  • No More Encoding Issues

    Forget charset nightmares and mojibake. Our email parser handles all encodings and delivers clean UTF-8 text every time.

  • No More Regex Parsing

    Stop writing fragile regex to extract headers and content. Get structured JSON with everything pre-parsed.

  • How Email Parsing Works

    CloudMailin's email parser extracts every piece of data from your emails and delivers it in a clean, structured format.

    • 1. Email Arrives

      Emails are sent to your CloudMailin address or custom domain. Our servers receive and queue the message instantly.

    • 2. We Parse Everything

      Headers are decoded, MIME parts separated, attachments extracted, and character encodings normalized to UTF-8.

    • 3. Clean JSON Delivered

      Your webhook receives structured JSON with headers, plain text, HTML, and attachments - ready to use in your application.

    Email parsing flow - raw email to structured JSON
  • Attachment Extraction Made Simple

    Every attachment is automatically extracted, decoded from base64, and delivered with metadata. No parsing libraries required.

    Store attachments directly in your cloud storage (AWS S3, Google Cloud, Azure) or receive them inline with your webhook.

    app.post('/incoming_mails', (req, res) => {
      const { headers, attachments } = req.body;
    
      // Pre-parsed - no regex needed
      const subject = headers.subject;
    
      // Attachments already decoded
      attachments.forEach(file => {
        const buffer = Buffer.from(file.content, 'base64');
        fs.writeFileSync(file.file_name, buffer);
      });
    
      res.status(200).json({ status: 'ok' });
    });
  • Works with Any Language or Framework

    Because CloudMailin delivers parsed email via HTTP POST, you can use any programming language or framework. No SDK required - just parse the JSON.

    Node.js, Python, Ruby, PHP, Go, Rust, TypeScript, Java, C#... if it can handle an HTTP request, it works with CloudMailin.

    See examples for all languages

    Email parser works with any framework - Node.js, Ruby, Python, PHP, Go
  • Every Header, Every Format

    Our email parser handles the full complexity of email formats so your code stays simple.

    • Encoded Headers

      RFC 2047 encoded subjects and sender names are automatically decoded. No more =?UTF-8?B?...?= in your data.

    • HTML & Plain Text

      Both versions extracted and delivered. We even extract the reply portion separately for threaded conversations.

    • Nested Attachments

      Forwarded emails, inline images, and deeply nested MIME structures are all parsed correctly.

    Email parser handles all email formats and encodings

Testimonials

Don't just take our word for it

CloudMailin has been instrumental in our growth at ExpressSteuer. The system is not only incredibly easy to implement, but also highly reliable and robust. What's more, their support team is simply amazing - always quick to respond and provide effective solutions to any challenge we encounter. We couldn't be more pleased with the service provided by CloudMailin!
Profile Picture
Andreas Santoro
CTO, ExpressSteuer
Thanks for the rock solid decade
Profile Picture
Dan
CamelCamelCamel.com
The product is perfect, feature rich, nice and intuitive UI and great support. It was really easy to integrate it into our application. It enables our application to receive inbound traffic, to give better support to clients and to expand our mailing options.
Profile Picture
Francisco (Kiko) R.
Head of Engineering, ProFinda.com

Start Parsing Emails in Minutes

The first 10,000 emails per month are free. No credit card required.

Get Started View Documentation