Subject: [Jmap] I made a tool to convert email to JMAP compatible JSON

From: "Seph Gentle" <[email-masked]>
Date: Sat, 13 Jun 2020 06:23:06 +0000

Hi everyone!

At the hackathon in Singapore last year Neil Jenkins and I tried to make a JMAP wrapper around gmail's API. But we ran into a problem converting RFC822 message envelopes into JMAP objects.

So with a bit of help from Bron (brong) I extracted the email-to-JMAP codepath out of cyrus-imapd. (Cyrus underpins Fastmail). Anyway the end result is now we have a spec compliant, standalone C library / tool to convert email objects to JMAP-compatible json. It gives nice, clean, usable HTML from any email, extracts attachments, and all the other good stuff.

I'd love to see some alternate implementations in other languages. The extracted C code isn't particularly maintainable, but I figure this would provide a great basis for spec conformance testing. And its definitely usable on its own.

I also compiled the code to WASM and wrapped it in a nodejs library so you can convert emails to jmap json from nodejs or directly from the browser.

If you have some emails kicking around, have a play! This is a browser-only email viewer which internally loads and displays emails via jmap's format:

https://josephg.com/mail-viewer/

Code:
https://github.com/josephg/mime-to-jmap

NPM package (containing pre-compiled wasm bundle. Building it yourself is a huge pain because of libicu):
https://www.npmjs.com/package/mime-to-jmap

Hope someone finds it useful!
-Seph

---

From: <[email-masked]>
Date: Sat, 13 Jun 2020 07:37:54 -0400

Dear Seth,

Thank you very much for your contribution! Interesting use of WASM.

Can you add here?
https://jmap.io/software.html

Best regards,

Marc

On Sat, 13 Jun 2020 06:23:06 +0000 Seph Gentle [email-masked] said

> Hi everyone!
> 
> At the hackathon in Singapore last year Neil Jenkins and I tried to make a
> JMAP wrapper around gmail's API. But we ran into a problem converting RFC822
> message envelopes into JMAP objects.
> 
> So with a bit of help from Bron (brong) I extracted the email-to-JMAP
> codepath out of cyrus-imapd. (Cyrus underpins Fastmail). Anyway the end
> result is now we have a spec compliant, standalone C library / tool to
> convert email objects to JMAP-compatible json. It gives nice, clean, usable
> HTML from any email, extracts attachments, and all the other good stuff.
> 
> I'd love to see some alternate implementations in other languages. The
> extracted C code isn't particularly maintainable, but I figure this would
> provide a great basis for spec conformance testing. And its definitely usable
> on its own.
> 
> I also compiled the code to WASM and wrapped it in a nodejs library so you
> can convert emails to jmap json from nodejs or directly from the browser.
> 
> If you have some emails kicking around, have a play! This is a browser-only
> email viewer which internally loads and displays emails via jmap's format:
> 
> _______________________________________________
> Jmap mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/jmap

---

From: "Seph Gentle" <[email-masked]>
Date: Sat, 13 Jun 2020 11:49:05 +0000

Thanks; and absolutely!

Its a bit difficult to build and use from C at the moment - I haven't set up a shim / API / CLI tool to make that easy. Let me know if thats something folks are interested in.

-Seph