20 lines
617 B
TypeScript
20 lines
617 B
TypeScript
import { MailerService } from '@nestjs-modules/mailer';
|
|
import { Injectable } from '@nestjs/common';
|
|
|
|
@Injectable()
|
|
export class MailService {
|
|
constructor(private mailerService: MailerService) { }
|
|
|
|
|
|
async sendEmail(templateName: string, subject: string, context: any, toEmail: string, ccEmails?: string[], bccEmails?: string[]) {
|
|
await this.mailerService.sendMail({
|
|
to: toEmail,
|
|
cc: ccEmails,
|
|
bcc: bccEmails,
|
|
subject: subject,
|
|
template: templateName, // `.hbs` extension is appended automatically
|
|
context,
|
|
})
|
|
}
|
|
}
|