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

multi-mailer

v1.0.4

Published

A flexible and easy-to-use email sending package supporting multiple providers like Brevo and Mailjet, with support for HTML and Pug templates.

Downloads

43

Readme

Multi-Mailer

Multi-Mailer is a flexible and easy-to-use email sending package that supports multiple providers like Brevo, Mailjet, SendGrid, and Mailgun. It allows you to send emails using HTML and Pug templates with ease.

Features

  • Support for multiple email providers (e.g., Brevo, Mailjet, SendGrid, Mailgun).
  • Send emails with dynamic data using HTML or Pug templates.
  • Easy configuration using environment variables.
  • Attachments support.

Installation

To install the package, run:

npm install multi-mailer

Configuration

Create a .env file in the root directory of your project and configure the following variables based on your SMTP provider.

For Brevo

MAIL_HOST=smtp-relay.brevo.com
MAIL_PORT=587
MAIL_USERNAME=your_brevo_username
MAIL_PASSWORD=your_brevo_password
MAIL_SECURE=false
[email protected]
TEMPLATE_PATH=src/core/helpers/mails/

For Mailjet

MAIL_HOST=in-v3.mailjet.com
MAIL_PORT=587
MAIL_USERNAME=your_mailjet_public_api_key
MAIL_PASSWORD=your_mailjet_private_api_key
MAIL_SECURE=false
[email protected]
TEMPLATE_PATH=src/core/helpers/mails/

For SendGrid

MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=apikey # Use "apikey" as the username for SendGrid
MAIL_PASSWORD=your_sendgrid_api_key
MAIL_SECURE=false
[email protected]
TEMPLATE_PATH=src/core/helpers/mails/

For Mailgun

MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=your_mailgun_username
MAIL_PASSWORD=your_mailgun_password
MAIL_SECURE=false
[email protected]
TEMPLATE_PATH=src/core/helpers/mails/

Note: Ensure that the TEMPLATE_PATH environment variable points to the directory containing your email templates. For example, if your template is located at src/core/helpers/mails/welcome.html, set TEMPLATE_PATH=src/core/helpers/mails/.

Usage

Sending an Email

Here's an example of how to send a welcome email:

import {EmailService} from 'multi-mailer';

async function sendWelcomeEmail(recipientEmail: string, userName: string) {
    // Initialize the EmailService with the recipient's email
    const emailService = new EmailService(recipientEmail);

    // Define the template and parameters
    const template = "welcome.html"; // Name of the template file (e.g., welcome.html)
    const params = {
        name: userName, // Dynamic name for the template
    };

    try {
        // Send the email
        await emailService.sendEmail(template, "Welcome to Our Service", params);
        console.log(`Welcome email sent successfully to ${recipientEmail}!`);
    } catch (error) {
        console.error(`Failed to send welcome email to ${recipientEmail}:`, error);
    }
}

// Example usage: Sending a welcome email to a dynamic recipient
const recipientEmail = "[email protected]"; // Replace with the recipient's email
const userName = "John Doe"; // Replace with the user's name
sendWelcomeEmail(recipientEmail, userName);

Templates

Place your email templates in the directory specified by the TEMPLATE_PATH environment variable. Supported formats are .html and .pug.

Example welcome.html:

<html>
  <body>
    <h1>Welcome, {{name}}!</h1>
    <p>Thank you for joining our service.</p>
  </body>
</html>

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

Author

Abdullateef Mubarak