@spreadmonitor/nest-mailer-module
v1.1.0
Published
Re-usable NestJS module for sending emails via Mailgun.
Downloads
2
Readme
nest-mailgun-module
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. <[email protected]>',
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
- Author - Attila Olah
- Repository - spreadmonitor/nest-mailgun-module
License
This project is licensed under MIT.