Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@crowdlinker/nestjs-mailer

Package Overview
Dependencies
Maintainers
4
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@crowdlinker/nestjs-mailer

Mailer module for NestJS

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
141
increased by88%
Maintainers
4
Weekly downloads
 
Created
Source

NestJS Mailer

Mailer module for NestJS

Nest Logo

Packages

  • Nodemailer - nodemailer (v6.4.15)

Installation

npm install --save @crowdlinker/nestjs-mailer nodemailer
npm install --save-dev @types/nodemailer
// or
// yarn add @crowdlinker/nestjs-mailer nodemailer
// yarn add -D @types/nodemailer

Usage

Importing the Module

Synchronous
import { NodemailerModule } from '@crowdlinker/nestjs-mailer';
import { NodemailerDrivers } from '@crowdlinker/nestjs-mailer';
import { NodemailerOptions } from '@crowdlinker/nestjs-mailer';

@Module({
  imports: [
    NodemailerModule.forRoot({
      transport: {
        host: 'smtp.mailtrap.io',
        port: 2525,
        auth: {
          user: 'ccdff3b99c83ec',
          pass: 'a700a7eafe1e28',
        },
      },
      defaults: {
        from: 'Hello @Crowdlinker <hello@crowdlinker.com>',
      },
    } as NodemailerOptions<NodemailerDrivers.SMTP>),
  ],
})
Asynchronous
import { NodemailerModule } from '@crowdlinker/nestjs-mailer';
import { NodemailerOptions } from '@crowdlinker/nestjs-mailer';

@Module({
  imports: [
    NodemailerModule.forRootAsync({
      imports: [ConfigModule],
      useFactory: async (configService: ConfigService) =>
        ({
          transport: {
            host: configService.host,
            port: configService.port,
            secure: configService.secure,
            auth: {
              user: configService.username,
              pass: configService.password,
            },
          },
          defaults: {
            from: 'Hello @Crowdlinker <hello@crowdlinker.com>',
          },
        } as NodemailerOptions<NodemailerDrivers.SMTP>),
      inject: [ConfigService],
    }),
  ],
})

Importing in a Class/Service

import { Nodemailer } from '@crowdlinker/nestjs-mailer';

class MailService {
  constructor(
    private readonly nodemailer: Nodemailer<NodemailerDrivers.SMTP>
  ) {}

  async mail(to, subject, text, html) {
    this.nodemailer.sendMail({ to, subject, text, html });
  }
}

Drivers

You can use the following drivers

  1. NodemailerDrivers.SES - https://nodemailer.com/transports/ses/
  2. NodemailerDrivers.JSON - https://nodemailer.com/transports/stream/
  3. NodemailerDrivers.SMTP - https://nodemailer.com/smtp/
  4. NodemailerDrivers.SENDMAIL - https://nodemailer.com/transports/sendmail/

Important Points To Note

  • Code is written in Typescript (v3.6.3)

Contributors

Keywords

FAQs

Package last updated on 07 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc