1.1.0 • Published 2 years ago

@spreadmonitor/nest-mailer-module v1.1.0

Weekly downloads
347
License
MIT
Repository
github
Last release
2 years ago

nest-mailgun-module

Build Status codecov

Re-usable NestJS module for sending emails via Mailgun.

Installation

$ npm install @spreadmonitor/nest-mailgun-module

Usage

import { Module } from '@nestjs/common';
import { MailgunModule } from '@spreadmonitor/nest-mailgun-module';

import * as TEMPLATES from './email-templates';

@Module({
  imports: [
    MailgunModule.forRoot({
      templates: TEMPLATES,
      sender: 'Fancy Co. <no-reply@fancy.com>',
      mailgunApiKey: process.env['MAILGUN_API_KEY'],
      mailgunDomain: process.env['MAILGUN_DOMAIN'],
    }),
  ],
  exports: [MailgunModule],
})
export class CoreModule {}
import { SignupService } from '@app/auth/services';
import { MailService } from '@spreadmonitor/nest-mailgun-module';
import { WelcomeTemplate } from '@app/auth/email-templates';

@Controller('auth')
export class SignupController {
  constructor(private readonly signupService: SignupService, private readonly mailService: MailService) {}

  @Post('signup')
  async createAccount(@Body() payload: SignupPayload): string {
    await this.signupService.createAccount();

    await this.mailService.send(payload.email, WelcomeTemplate, {
      name: payload.name,
    });

    return { message: 'Yay! Account created!' };
  }
}

For detailed usage please read the documentation.

Contact

License

This project is licensed under MIT.

1.1.0

2 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago