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

@blacdot/nestjs-mailer

v1.2.4

Published

A nestjs mail client library

Downloads

20

Readme

A powerful, flexible email module featuring template support with Handlebars and seamless integration with various email transport providers.

Features

  • Easy Integration: Seamless integration with various email transport providers
  • Template Support: Built-in Handlebars template engine
  • Multiple Transport Providers: Works with any Nodemailer transport
  • Test-Friendly: Mock support for testing environments
  • Type Safe: Fully typed with TypeScript
  • Modular Design: Easy to extend and customize

Installation

npm install @blacdot/nestjs-mailer
# or
yarn add @blacdot/nestjs-mailer

Quick Start

  1. Install the required dependencies:
npm install @blacdot/nestjs-mailer @nestjs/core @nestjs/common
  1. Create a simple application (app.ts):

@Module({
  imports: [
    BlacdotMailerModule.forRoot({
      transporter: TransportType.NODEMAILER, // Use the NodeMailer transport, when you use the other named transports (not nodemailer) just supply the auth and defaults(also optional) options in the transportConfig
      transport: {
        host: 'smtp.example.com', // Replace with your SMTP server
        port: 587,
        secure: false,
        defaults: {
          from: '[email protected]', // Replace with your email, this will be used as the "from" address if not specified in the mailMessage object
        },
        auth: {
          user: '[email protected]', // Replace with your email
          pass: 'your-password', // Replace with your password
        },
      },
      template: {
        directory: __dirname + '/templates', // Path to your templates
      },
    }),
  ],
})
class AppModule {}

async function bootstrap() {
  try {
    // Create the application
    const app = await NestFactory.createApplicationContext(AppModule);

    // Get the MailerService
    const mailerService = app.get(BlacdotMailerService);

    // Send an email using a template
    const result = await mailerService.sendMail({
      to: '[email protected]', // Replace with recipient email
      subject: 'Welcome to Our Service',
      template: 'welcome', // This refers to welcome.hbs in the templates directory
      context: {
        name: 'John Doe',
        company: 'Acme Inc',
        year: new Date().getFullYear(),
      },
    });

    console.log('Email sent successfully!');
    console.log('Message ID:', result.messageId);

    // Close the application
    await app.close();
  } catch (error) {
    console.error('Error sending email:', error);
  }
}

bootstrap();
  1. Create a template file (templates/welcome.hbs):
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Welcome Email</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            color: #333;
            max-width: 600px;
            margin: 0 auto;
            padding: 20px;
        }

        .header {
            background-color: #4CAF50;
            color: white;
            padding: 10px 20px;
            text-align: center;
            border-radius: 5px 5px 0 0;
        }

        .content {
            padding: 20px;
            border: 1px solid #ddd;
            border-top: none;
            border-radius: 0 0 5px 5px;
        }

        .footer {
            text-align: center;
            margin-top: 20px;
            font-size: 12px;
            color: #777;
        }
    </style>
</head>
<body>
<div class="header">
    <h1>Welcome to {{company}}!</h1>
</div>
<div class="content">
    <p>Hello {{name}},</p>
    <p>Thank you for joining {{company}}. We're excited to have you on board!</p>
    <p>Here are some things you can do to get started:</p>
    <ul>
        <li>Complete your profile</li>
        <li>Explore our features</li>
        <li>Connect with other users</li>
    </ul>
    <p>If you have any questions, feel free to contact our support team.</p>
    <p>Best regards,<br>The {{company}} Team</p>
</div>
<div class="footer">
    &copy; {{year}} {{company}}. All rights reserved.
</div>
</body>
</html>
  1. Run the application:
# Compile TypeScript
npx tsc app.ts --esModuleInterop

# Run the application
node app.js

Template Usage

  1. Create a template file (e.g., templates/welcome.hbs):

<div>
    <h1>Welcome, {{name}}!</h1>
    <p>Thank you for joining our service.</p>
</div>
  1. Configure the template directory when initializing the mailer:
import { join } from 'path';

const mailer = new Mailer({
  // ... transport config
  template: {
    dir: join(__dirname, 'templates'),
  },
});

Testing

# Run tests
npm test

# Run tests in watch mode
npm run test:watch

# Run with coverage
npm run test:cov

Configuration Options

Mailer Options

| Option | Type | Description | |-------------|----------------------------------|-------------------------| | transport | Transport | TransportOptions | Nodemailer transport configuration | | defaults | Mail.Options | Default message options | | template | { dir: string, options?: any } | Template configuration |

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

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

Author

Jamie Omondi

Acknowledgments

License

This project is MIT licensed.