This commit is contained in:
@@ -5,27 +5,33 @@ import { MailerAsyncOptions } from "@nestjs-modules/mailer/dist/interfaces/maile
|
||||
export function mailerConfig(): MailerAsyncOptions {
|
||||
return {
|
||||
inject: [ConfigService],
|
||||
useFactory: (configService: ConfigService) => ({
|
||||
transport: {
|
||||
host: configService.getOrThrow<string>("SMTP_HOST"),
|
||||
port: configService.getOrThrow<number>("SMTP_PORT"),
|
||||
secure: true,
|
||||
auth: {
|
||||
user: configService.getOrThrow<string>("SMTP_USER"),
|
||||
pass: configService.getOrThrow<string>("SMTP_PASS"),
|
||||
},
|
||||
},
|
||||
defaults: {
|
||||
from: configService.getOrThrow<string>("MAIL_FROM"),
|
||||
},
|
||||
useFactory: (configService: ConfigService) => {
|
||||
const port = Number(configService.getOrThrow<number>("SMTP_PORT"));
|
||||
// 465 = implicit TLS; 587 = STARTTLS (required by zone-mta behind Traefik)
|
||||
const secure = port === 465;
|
||||
|
||||
template: {
|
||||
dir: process.cwd() + "/src/modules/templates/email",
|
||||
adapter: new HandlebarsAdapter(),
|
||||
options: {
|
||||
strict: true,
|
||||
return {
|
||||
transport: {
|
||||
host: configService.getOrThrow<string>("SMTP_HOST"),
|
||||
port,
|
||||
secure,
|
||||
requireTLS: !secure,
|
||||
auth: {
|
||||
user: configService.getOrThrow<string>("SMTP_USER"),
|
||||
pass: configService.getOrThrow<string>("SMTP_PASS"),
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
defaults: {
|
||||
from: configService.getOrThrow<string>("MAIL_FROM"),
|
||||
},
|
||||
template: {
|
||||
dir: process.cwd() + "/src/modules/templates/email",
|
||||
adapter: new HandlebarsAdapter(),
|
||||
options: {
|
||||
strict: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user