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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@mailiam/node

v0.2.0

Published

Official Node.js SDK for Mailiam - transactional email made simple

Readme

@mailiam/node

Official Node.js SDK for Mailiam - Transactional email made simple.

Installation

npm install @mailiam/node

Quick Start

import { Mailiam } from '@mailiam/node';

const mailiam = new Mailiam({
  apiKey: process.env.MAILIAM_API_KEY
});

// Send a single email
await mailiam.emails.send({
  from: '[email protected]',
  to: '[email protected]',
  subject: 'Welcome!',
  html: '<h1>Welcome to our service</h1>'
});

Features

  • TypeScript Support - Full type safety with TypeScript definitions
  • Automatic Retries - Built-in retry logic with exponential backoff
  • Rate Limit Handling - Respects 429 responses and retries appropriately
  • Batch Sending - Send multiple emails efficiently
  • Error Handling - Comprehensive error classes for different failure modes
  • Zero Dependencies - Uses native fetch API (Node.js 18+)

Usage

Get Your API Key

# Install Mailiam CLI
npm install -g mailiam

# Create an API key
mailiam keys create --name "Production" --type usage

Send a Single Email

import { Mailiam } from '@mailiam/node';

const mailiam = new Mailiam({
  apiKey: 'mlm_sk_...'
});

try {
  const result = await mailiam.emails.send({
    from: '[email protected]',
    to: '[email protected]',
    subject: 'Welcome!',
    html: '<h1>Welcome!</h1>',
    text: 'Welcome!', // Optional plain text version
    replyTo: '[email protected]', // Optional
    cc: ['[email protected]'], // Optional
    bcc: ['[email protected]'] // Optional
  });

  console.log('Email sent:', result.messageId);
} catch (error) {
  console.error('Failed to send:', error.message);
}

Send Batch Emails

const users = [
  { email: '[email protected]', name: 'Alice' },
  { email: '[email protected]', name: 'Bob' }
];

const emails = users.map(user => ({
  from: '[email protected]',
  to: user.email,
  subject: `Hello ${user.name}!`,
  html: `<h1>Hi ${user.name}!</h1>`
}));

const result = await mailiam.emails.sendBatch(emails);
console.log(`Sent: ${result.sent}, Failed: ${result.failed}`);

With Custom Configuration

const mailiam = new Mailiam({
  apiKey: 'mlm_sk_...',
  baseUrl: 'https://api.mailiam.dev', // Optional: Custom API URL
  timeout: 30000, // Optional: Request timeout in ms (default: 30000)
  maxRetries: 3, // Optional: Max retry attempts (default: 3)
  debug: false // Optional: Enable debug logging (default: false)
});

Error Handling

The SDK provides specific error classes for different failure modes:

import {
  Mailiam,
  AuthenticationError,
  RateLimitError,
  ValidationError,
  NetworkError,
  ApiError
} from '@mailiam/node';

try {
  await mailiam.emails.send({ ... });
} catch (error) {
  if (error instanceof AuthenticationError) {
    // Invalid API key
  } else if (error instanceof RateLimitError) {
    // Rate limit exceeded (429)
    console.log('Retry after:', error.retryAfter);
  } else if (error instanceof ValidationError) {
    // Invalid request data
  } else if (error instanceof NetworkError) {
    // Network/timeout error
  } else if (error instanceof ApiError) {
    // Other API error
    console.log('Status:', error.statusCode);
  }
}

Examples

See the examples directory for more detailed examples:

  • Basic Email - Simple single email
  • Batch Emails - Send multiple emails
  • Express.js - Integration with Express
  • Next.js API Route - Integration with Next.js

Requirements

  • Node.js 16.0.0 or higher
  • Native fetch support (Node.js 18+) or a fetch polyfill

License

MIT

Support

  • Documentation: https://mailiam.io/docs
  • Issues: https://github.com/mailiam/mailiam/issues
  • Email: [email protected]