Skip to content

NestJS provider for sending emails with resend

Notifications You must be signed in to change notification settings

weecraft/nestjs-resend

 
 

Repository files navigation

Nest Logo

A simple nestjs wrapper of Resend. It support send mail only

NPM Version Package License NPM Downloads

Features

  1. send email

Installation

# npm
$ npm install nestjs-resend

# yarn
$ yarn add nestjs-resend

# pnpm
$ pnpm add nestjs-resend

Usage

Importing module

import { ResendModule } from 'nestjs-resend';

@Module({
  imports: [
    ResendModule.forRoot({
      apiKey: 'your resend api key',
    }),
  ],
  providers: [],
  exports: [],
})

Importing module async

import { ResendModule } from 'nestjs-resend';

@Module({
  imports: [
    ResendModule.forAsyncRoot({
      useFactory: async () => ({
        apiKey: 'your resend api key',
      })
    }),
  ],
  providers: [],
  exports: [],
})

Interfaces

interface Options {
  apiKey: string;
}

Calling Send Method

import { ResendService } from 'nestjs-resend';

@Injectable()
export class YourService {
  constructor(private readonly resendService: ResendService) {

    // text
    await this.resendService.send({
      from: '[email protected]',
      to: '[email protected]',
      subject: 'hello world',
      text: 'it works!',
    });

    // html
    await this.resendService.send({
      from: '[email protected]',
      to: '[email protected]',
      subject: 'hello world',
      html: '<strong>it works!</strong>',
    });

    // react
    await this.resendService.send({
      from: '[email protected]',
      to: '[email protected]',
      subject: 'hello world',
      react: <EmailTemplate firstName="John" product="MyApp" />,
    });

    // To include a friendly name, use the format "Your Name <[email protected]>"
    await this.resendService.send({
      from: 'Your Name <[email protected]>',
      to: '[email protected]',
      subject: 'hello world',
      react: <EmailTemplate firstName="John" product="MyApp" />,
    });
  }

License

Nestjs-Resend is MIT licensed.

About

NestJS provider for sending emails with resend

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 76.2%
  • JavaScript 23.8%