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

mail-notifier-sdk

v1.2.5

Published

SDK for the Email Monitoring Service

Readme

Mail Notifier SDK

A simple SDK for interacting with the Email Monitoring Service. This SDK allows you to easily send email notifications with different event types (error, success, warning, info) and customizable content.

Installation

npm install mail-notifier-sdk
# or
yarn add mail-notifier-sdk

Quick Start

Initialize the SDK

import MailNotifierSDK from 'mail-notifier-sdk';

// Initialize with your API token
const mailNotifier = new MailNotifierSDK('https://mail-notifier-production.up.railway.app', 'your-api-token');

// Or use the default URL
const mailNotifier = new MailNotifierSDK(undefined, 'your-api-token');

Send a Basic Email

const sendEmail = async () => {
  try {
    const result = await mailNotifier.sendEmail({
      to: '[email protected]',
      subject: 'Hello from Mail Notifier SDK',
      content: 'This is a test email sent from the Mail Notifier SDK.',
      eventType: 'info',
      impactLevel: 'low'
    });
    
    console.log('Email sent successfully:', result);
  } catch (error) {
    console.error('Failed to send email:', error);
  }
};

Usage Guide

Sending Different Types of Emails

The SDK provides convenience methods for sending emails with different event types:

Info Email

await mailNotifier.sendInfo({
  to: '[email protected]',
  subject: 'Information Notification',
  content: 'This is an informational message.',
  impactLevel: 'low'
});

Error Email

await mailNotifier.sendError({
  to: '[email protected]',
  subject: 'Error Notification',
  content: 'An error occurred in the application.',
  impactLevel: 'high',
  sourceApplication: 'backend-service'
});

Warning Email

await mailNotifier.sendWarning({
  to: '[email protected]',
  subject: 'Warning Notification',
  content: 'This is a warning message.',
  impactLevel: 'medium'
});

Success Email

await mailNotifier.sendSuccess({
  to: '[email protected]',
  subject: 'Success Notification',
  content: 'Operation completed successfully!',
  impactLevel: 'low'
});

Customizing Email Payloads

You can customize your emails with additional options:

Multiple Recipients

await mailNotifier.sendInfo({
  to: ['[email protected]', '[email protected]'],
  subject: 'Notification for Multiple Recipients',
  content: 'This email is sent to multiple recipients.'
});

Adding Metadata

await mailNotifier.sendError({
  to: '[email protected]',
  subject: 'Error with Metadata',
  content: 'Error details with additional metadata.',
  metadata: {
    errorCode: 'ERR_123',
    timestamp: new Date().toISOString(),
    requestId: 'req-456-abc',
    userInfo: {
      id: 123,
      username: 'testuser'
    }
  }
});

Adding Attachments

await mailNotifier.sendInfo({
  to: '[email protected]',
  subject: 'Email with Attachments',
  content: 'Please find the attached files.',
  attachments: [
    {
      filename: 'report.pdf',
      content: Buffer.from('PDF content here')
    },
    {
      filename: 'data.json',
      content: JSON.stringify({ key: 'value' })
    }
  ]
});

Using Custom SMTP Credentials

await mailNotifier.sendEmail({
  to: '[email protected]',
  subject: 'Email with Custom SMTP',
  content: 'This email is sent using custom SMTP settings.',
  eventType: 'info',
  customCredentials: {
    host: 'smtp.custom-server.com',
    port: 587,
    secure: false,
    user: 'smtp-username',
    pass: 'smtp-password'
  }
});

Checking Server Status

You can check the status of the email notification service:

const checkServerStatus = async () => {
  try {
    const status = await mailNotifier.getStatus();
    console.log('Server status:', status);
    // Example output: { status: 'online', message: 'Server is healthy' }
  } catch (error) {
    console.error('Failed to check server status:', error);
  }
};

API Reference

MailNotifierSDK Class

Constructor

constructor(baseUrl: string = 'https://mail-notifier-production.up.railway.app', token: string)
  • baseUrl: (Optional) The base URL of the Mail Notifier service
  • token: Your API token for authentication

Methods

sendEmail(payload: EmailPayload): Promise<{ message: string; eventType: string }>

Sends an email with the specified payload.

getStatus(): Promise<{ status: string; message: string }>

Retrieves the current status of the Mail Notifier service.

Convenience Methods
  • sendInfo(payload: Omit<EmailPayload, 'eventType'>): Sends an info email
  • sendError(payload: Omit<EmailPayload, 'eventType'>): Sends an error email
  • sendWarning(payload: Omit<EmailPayload, 'eventType'>): Sends a warning email
  • sendSuccess(payload: Omit<EmailPayload, 'eventType'>): Sends a success email

EmailPayload Interface

interface EmailPayload {
  to?: string | string[];                 // Recipient email address(es)
  subject: string;                        // Email subject line
  content: string;                        // Email body content
  eventType?: 'error' | 'success' | 'warning' | 'info';  // Type of event
  impactLevel?: 'critical' | 'high' | 'medium' | 'low';  // Impact severity
  sourceApplication?: string;             // Source application identifier
  metadata?: Record<string, any>;         // Additional metadata as key-value pairs
  attachments?: Array<{                   // File attachments
    filename: string;
    content: string | Buffer;
  }>;
  customCredentials?: {                   // Custom SMTP server credentials
    host: string;
    port: number;
    secure: boolean;
    user: string;
    pass: string;
  };
}

Error Handling

The SDK throws errors for failed requests. Always wrap your calls in try/catch blocks:

try {
  await mailNotifier.sendEmail({...});
} catch (error) {
  // Handle error
  console.error('Error sending email:', error.message);
}