mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { Module } from '@nestjs/common';
|
|
import { ConfigService } from '@nestjs/config';
|
|
import { createTransport } from 'nodemailer';
|
|
import { MAIL_TRANSPORTER_PROVIDER } from './Mail.constants';
|
|
import { MailTransporter } from './MailTransporter.service';
|
|
|
|
@Module({
|
|
imports: [
|
|
{
|
|
module: MailModule,
|
|
providers: [
|
|
{
|
|
provide: MAIL_TRANSPORTER_PROVIDER,
|
|
useFactory: (configService: ConfigService) => {
|
|
// Create reusable transporter object using the default SMTP transport
|
|
const transporter = createTransport({
|
|
host: configService.get('mail.host'),
|
|
port: configService.get('mail.port'),
|
|
secure: configService.get('mail.secure'), // true for 465, false for other ports
|
|
auth: {
|
|
user: configService.get('mail.username'),
|
|
pass: configService.get('mail.password'),
|
|
},
|
|
});
|
|
return transporter;
|
|
},
|
|
},
|
|
],
|
|
},
|
|
MailTransporter
|
|
],
|
|
})
|
|
export class MailModule {}
|