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

@bernierllc/inbound-email-parse

v1.3.1

Published

Inbound email receiving, parsing, and routing service with webhook endpoints for all major providers and rule-based routing to downstream systems

Downloads

239

Readme

@bernierllc/inbound-email-parse

Inbound email receiving, parsing, and routing service that provides webhook endpoints for all major email providers, MIME parsing with attachment handling, and rule-based routing to downstream systems.

Installation

npm install @bernierllc/inbound-email-parse

Usage

import { InboundEmailParser } from '@bernierllc/inbound-email-parse';

const parser = new InboundEmailParser({
  providers: [
    {
      provider: 'sendgrid',
      enabled: true,
      signingSecret: process.env.SENDGRID_SIGNING_SECRET
    }
  ],
  defaultRoutingRules: [
    {
      id: 'route-to-support',
      name: 'Route support emails',
      priority: 100,
      enabled: true,
      conditions: [
        { type: 'to', field: 'address', operator: 'contains', value: 'support@' }
      ],
      actions: [
        {
          type: 'route',
          destination: {
            type: 'neverhub',
            config: { eventType: 'support.email.received' }
          }
        }
      ]
    }
  ]
});

await parser.initialize();

// Process inbound email from webhook
const result = await parser.processInbound('sendgrid', webhookPayload, signature);

if (result.success) {
  console.log(`Processed email: ${result.emailId}`);
  console.log(`Routed to ${result.routed.length} destinations`);
}

Features

  • Multi-Provider Support: SendGrid, Postmark, Mailgun, AWS SES, and generic MIME
  • Webhook Signature Validation: Secure webhook receiving with signature verification
  • MIME Parsing: Full email parsing including headers, body, and attachments
  • Attachment Processing: Handle attachments with size limits, type validation, and checksums
  • Rule-Based Routing: Flexible routing engine with conditions and actions
  • Multi-Destination: Route single email to multiple systems simultaneously
  • NeverHub Integration: Publish events and subscribe to routing updates
  • Cross-Suite Compatibility: Used by Email Suite, Chat Suite, Content Management Suite, and Task Suite

Provider Capability Support

This section documents how inbound email parsing behaves across email providers, based on the canonical CAPABILITY_MATRIX in @bernierllc/email-manager.

Capability Levels by Provider

| Provider | Capability Level | Notes | |----------|-----------------|-------| | SendGrid | enhanced | Provider-level Inbound Parse webhook + platform normalization and routing | | Mailgun | enhanced | Provider-level Routes for inbound email + platform normalization and routing | | Postmark | enhanced | Provider-level Inbound webhook + platform normalization and routing | | SES | enhanced | Provider-level receiving rules via SNS + Lambda + platform normalization and routing | | SMTP | unsupported | SMTP does not provide inbound email parsing |

How It Works

  • Enhanced (SendGrid, Mailgun, Postmark): The email provider receives inbound emails on your behalf and forwards the parsed content (headers, body, attachments) to a webhook endpoint. This package receives those payloads, validates signatures, performs additional MIME parsing if needed, processes attachments (size validation, checksums), and routes emails through the rule-based routing engine.

  • Enhanced with extra infrastructure (SES): SES can receive inbound emails via SES receiving rules, which trigger SNS notifications or Lambda functions. The raw email is delivered to S3 or forwarded to an endpoint. This package parses the SES-specific payload format and applies the same normalization and routing as other providers.

  • Unsupported (SMTP): Plain SMTP is a sending protocol; it does not provide inbound email parsing or webhook forwarding. SMTP servers can receive email, but there is no standardized webhook mechanism to forward parsed content to an application.

Degradation Behavior

When used with an unsupported provider (SMTP):

  • Strategy: No automatic fallback -- SMTP does not support inbound parsing
  • Impact: Inbound email features are completely unavailable
  • Workaround: SMTP users who need inbound email parsing should either:
    1. Use a provider with native inbound support (SendGrid, Mailgun, Postmark, SES)
    2. Set up a separate inbound email gateway (e.g., a Postmark inbound-only configuration) alongside the SMTP sending provider
    3. Use a dedicated inbound email service that provides webhook forwarding

Override Options

The inbound email parsing capability is not marked as overridable at the provider level since it depends on provider-specific webhook formats. However, you can customize the processing pipeline:

  • Custom routing rules: Define rules that match on sender, recipient, subject, headers, or body content
  • Custom actions: Route parsed emails to any destination (NeverHub events, HTTP endpoints, message queues)
  • Custom attachment processing: Override size limits, allowed MIME types, and storage backends
const parser = new InboundEmailParser({
  providers: [{ provider: 'sendgrid', enabled: true }],
  defaultRoutingRules: [
    {
      id: 'custom-route',
      name: 'Route invoices to billing',
      priority: 100,
      enabled: true,
      conditions: [
        { type: 'subject', field: 'text', operator: 'contains', value: 'invoice' },
      ],
      actions: [
        { type: 'route', destination: { type: 'http', config: { url: 'https://billing.example.com/inbound' } } },
      ],
    },
  ],
});

SES-Specific Notes

SES inbound email requires additional AWS infrastructure:

  • SES receiving rules must be configured for the target domain
  • An SNS topic or Lambda function forwards the parsed email to this package's endpoint
  • Raw emails may be stored in S3 for large message handling
  • MX records for the domain must point to SES inbound SMTP endpoints

API Reference

[Complete API documentation will be generated with TypeDoc]

Configuration

See Configuration Guide for detailed configuration options.

Integration Status

  • Logger: integrated - Comprehensive logging for all operations
  • Docs-Suite: ready - TypeDoc format
  • NeverHub: required - Event publishing and service discovery

License

Copyright (c) 2025 Bernier LLC. All rights reserved.