npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rafters/mail-cloudflare

v0.1.0

Published

Cloudflare Email Routing inbound adapter and R2 blob storage for @rafters/mail

Downloads

250

Readme

@rafters/mail-cloudflare

Cloudflare inbound email adapter for @rafters/mail. R2 blob storage implementation, RFC 5322 email header parsing, and content hashing for idempotent ingestion.

Pairs Cloudflare Email Routing (inbound) with R2 (blob storage) to give you the two hardest pieces of edge email: receiving raw messages and storing them somewhere durable.

Install

pnpm add @rafters/mail-cloudflare @rafters/mail

Usage

R2 blob storage

import { createR2Storage } from "@rafters/mail-cloudflare/storage";

const storage = createR2Storage(env.BLOB_STORAGE);

await storage.put("messages/msg-123/raw.eml", rawEmailBuffer);
const raw = await storage.get("messages/msg-123/raw.eml");

createR2Storage implements the BlobStorage interface from @rafters/mail, so it drops into any service that expects a blob store.

Email parsing

import { parseEmailHeaders, hashContent } from "@rafters/mail-cloudflare/parsing";

const headers = parseEmailHeaders(rawEmail);
// { messageId, from, to, subject, references, inReplyTo, date, ... }

const hash = await hashContent(rawEmail);
// sha256 for dedupe and integrity checks

Inbound Email Routing handler

Wire Email Routing to a Worker that stores the raw email in R2, parses headers, dedupes by hash, and hands off to your threading service:

export default {
  async email(message: ForwardableEmailMessage, env: Env, ctx: ExecutionContext) {
    const raw = await new Response(message.raw).arrayBuffer();
    const hash = await hashContent(new Uint8Array(raw));

    if (await env.DB.get("messages", { hash })) return; // already ingested

    const headers = parseEmailHeaders(new TextDecoder().decode(raw));
    const storage = createR2Storage(env.BLOB_STORAGE);
    await storage.put(`messages/${hash}/raw.eml`, new Uint8Array(raw));

    // Thread matching, DB insert, classification dispatch, etc.
  },
};

Exports

| Subpath | What | | ----------- | ------------------------------------------------------ | | . | Top-level re-exports | | ./storage | createR2Storage (R2 implementation of BlobStorage) | | ./parsing | parseEmailHeaders, hashContent |

Documentation

Per-package docs ship in the docs/ directory and on npm:

  • quickstart.md -- Cloudflare Workers + D1 + R2 + Email Routing setup, from zero to receiving email
  • inbound.md -- Inbound email flow: parsing, dedupe, blob storage, thread matching
  • blob-storage.md -- Raw email + parsed body storage in R2, key schema, retrieval

See the monorepo README for the complete framework overview.

License

MIT