I'm using nest-modules/mailer
to send an email and I have some trouble during the config setup for MailerModule
.
(1) Previously I was using a raw dotenv
package to my config in main.ts
like:
dotenv.config({
path: 'src/config/config.env',
});
But I can't assign the config to MailerModule
in app.module.ts
.
(2) Then I tried to setup config using @nesjs/config
and the app.module.ts
looks like this:
import config from 'src/config/config';
@Module({
controllers: [
//...
],
providers: [
//...
],
imports: [
HttpModule,
ConfigModule.forRoot({
load: [config]
}),
MailerModule.forRoot({
transport: {
ignoreTLS: true,
secure: false, // true for 465, false for other ports
host: process.env.EMAIL_HOST,
port: process.env.EMAIL_PORT,
auth: {
user: process.env.EMAILDEV_INCOMING_USER,
pass: process.env.EMAILDEV_INCOMING_PWD
},
},
defaults: {
from: `'nest-modules' ${process.env.EMAILDEV_INCOMING_}`, // outgoing email ID
},
template: {
},
})
]
})
export class AppModule implements NestModule {
//...
}
So there's no way I can use configService
and process.env.*
to load the config for MailerModule
.
How should I fix this?