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

@flusys/nestjs-email

v5.3.0

Published

Modular email package with SMTP, SendGrid, and Mailgun providers

Readme

@flusys/nestjs-email

Database-driven email system for NestJS — multi-provider (SMTP, SendGrid, Mailgun), template engine with {{variable}} interpolation, and company scoping.

npm version License: MIT


Installation

npm install @flusys/nestjs-email @flusys/nestjs-shared @flusys/nestjs-core

# Provider SDKs — install only what you use
npm install nodemailer           # SMTP (default, always safe to install)
npm install @sendgrid/mail       # SendGrid
npm install mailgun.js form-data # Mailgun

1. Module Registration

forRoot (sync)

Mode 1: Single Database

import { EmailModule } from '@flusys/nestjs-email';

@Module({
  imports: [
    EmailModule.forRoot({
      global: true,
      includeController: true,
      bootstrapAppConfig: {
        databaseMode: 'single',
        enableCompanyFeature: false,
      },
      config: {
        defaultDatabaseConfig: {
          type: 'mysql',
          host: process.env.DB_HOST,
          port: Number(process.env.DB_PORT ?? 3306),
          username: process.env.DB_USER,
          password: process.env.DB_PASSWORD,
          database: process.env.DB_NAME,
        },
      },
    }),
  ],
})
export class AppModule {}

Mode 2: Multi-Tenant

EmailModule.forRoot({
  global: true,
  includeController: true,
  bootstrapAppConfig: {
    databaseMode: 'multi-tenant',
    enableCompanyFeature: true,
  },
  config: {
    tenantDefaultDatabaseConfig: {
      type: 'mysql',
      host: process.env.TENANT_DB_HOST,
      port: Number(process.env.TENANT_DB_PORT ?? 3306),
      username: process.env.TENANT_DB_USER,
      password: process.env.TENANT_DB_PASSWORD,
      database: process.env.TENANT_DB_NAME,
    },
    tenants: [
      { id: 'tenant-a', database: 'tenant_a_db' },
      { id: 'tenant-b', database: 'tenant_b_db' },
    ],
  },
});

forRootAsync (factory)

import { ConfigModule, ConfigService } from '@nestjs/config';
import { EmailModule, ITenantDatabaseConfig } from '@flusys/nestjs-email';

// Single database
EmailModule.forRootAsync({
  global: true,
  includeController: true,
  bootstrapAppConfig: {
    databaseMode: 'single',
    enableCompanyFeature: true,
  },
  imports: [ConfigModule],
  useFactory: (config: ConfigService) => ({
    defaultDatabaseConfig: {
      type: 'mysql',
      host: config.get('DB_HOST'),
      port: config.get<number>('DB_PORT'),
      username: config.get('DB_USER'),
      password: config.get('DB_PASSWORD'),
      database: config.get('DB_NAME'),
    },
  }),
  inject: [ConfigService],
});

// Multi-tenant
EmailModule.forRootAsync({
  global: true,
  includeController: true,
  bootstrapAppConfig: {
    databaseMode: 'multi-tenant',
    enableCompanyFeature: true,
  },
  imports: [ConfigModule],
  useFactory: (config: ConfigService) => ({
    tenantDefaultDatabaseConfig: {
      type: 'mysql',
      host: config.get('TENANT_DB_HOST'),
      port: config.get<number>('TENANT_DB_PORT'),
      username: config.get('TENANT_DB_USER'),
      password: config.get('TENANT_DB_PASSWORD'),
      database: config.get('TENANT_DB_NAME'),
    },
    tenants: config.get<ITenantDatabaseConfig[]>('TENANTS'),
  }),
  inject: [ConfigService],
});

2. Register Entities

import { getEmailEntitiesByConfig } from '@flusys/nestjs-email/entities';

TypeOrmModule.forRoot({
  entities: [
    ...getEmailEntitiesByConfig(false), // match enableCompanyFeature in bootstrapAppConfig
  ],
});

| enableCompanyFeature | Entities registered | | ---------------------- | ---------------------------------------------------- | | false | EmailConfig, EmailTemplate | | true | EmailConfigWithCompany, EmailTemplateWithCompany |

3. Send Emails

Via template

Create a template first:

POST /email/email-template/insert
{
  "name": "Welcome",
  "slug": "welcome",
  "subject": "Welcome, {{userName}}!",
  "htmlContent": "<h1>Hello {{userName}}</h1><p>Welcome to {{appName}}.</p>",
  "isHtml": true
}

Then send it from your service:

import { EmailSendService } from '@flusys/nestjs-email';

@Injectable()
export class UserService {
  constructor(@Inject(EmailSendService) private readonly emailSend: EmailSendService) {}

  async sendWelcome(user: { email: string; name: string }): Promise<void> {
    await this.emailSend.sendTemplateEmail({
      templateSlug: 'welcome', // or templateId: 'uuid'
      to: user.email,
      variables: { userName: user.name, appName: 'My App' },
    });
  }
}

All {{variable}} values in HTML are HTML-escaped automatically.

Raw email with attachments

await this.emailSend.sendEmail({
  to: '[email protected]',
  subject: 'Your Report',
  html: '<p>See attached.</p>',
  attachments: [
    {
      filename: 'report.pdf',
      content: base64String, // base64-encoded file content
      contentType: 'application/pdf',
    },
  ],
});

License

MIT © FLUSYS