import { ConfigService } from "@nestjs/config"; import { HandlebarsAdapter } from "@nestjs-modules/mailer/dist/adapters/handlebars.adapter"; import { MailerAsyncOptions } from "@nestjs-modules/mailer/dist/interfaces/mailer-async-options.interface"; export function mailerConfig(): MailerAsyncOptions { return { inject: [ConfigService], useFactory: (configService: ConfigService) => ({ transport: { host: configService.getOrThrow("SMTP_HOST"), port: configService.getOrThrow("SMTP_PORT"), secure: false, auth: { user: configService.getOrThrow("SMTP_USER"), pass: configService.getOrThrow("SMTP_PASS"), }, }, defaults: { from: configService.getOrThrow("MAIL_FROM"), }, template: { dir: process.cwd() + "/src/templates", adapter: new HandlebarsAdapter(), options: { strict: true, }, }, }), }; }