0.0.3 • Published 7 months ago

nestjs-resend v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

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.forRootAsync({
      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: 'you@example.com',
      to: 'user@gmail.com',
      subject: 'hello world',
      text: 'it works!',
    });

    // html
    await this.resendService.send({
      from: 'you@example.com',
      to: 'user@gmail.com',
      subject: 'hello world',
      html: '<strong>it works!</strong>',
    });

    // react
    await this.resendService.send({
      from: 'you@example.com',
      to: 'user@gmail.com',
      subject: 'hello world',
      react: <EmailTemplate firstName="John" product="MyApp" />,
    });

    // To include a friendly name, use the format "Your Name <sender@domain.com>"
    await this.resendService.send({
      from: 'Your Name <you@example.com>',
      to: 'user@gmail.com',
      subject: 'hello world',
      react: <EmailTemplate firstName="John" product="MyApp" />,
    });
  }

License

Nestjs-Resend is MIT licensed.

0.0.3

7 months ago

0.0.2

10 months ago

0.0.1

10 months ago