import { Injectable } from '@nestjs/common'; import * as nodemailer from 'nodemailer'; import { Utility } from 'src/common/Utility'; @Injectable() export class MailService { private transporter: nodemailer.Transporter; constructor() { this.transporter = nodemailer.createTransport(Utility.mailConfig.transport); } async sendMail(to: string, subject: string, text: string, html?: string) { const info = await this.transporter.sendMail({ from: Utility.mailConfig.defaults.from, to, subject, text, html, }); console.log('Email sent:', info.messageId); return info; } }