Closed GFoniX closed 10 months ago
Same issue, just need to close transporter after module desstroy. Now I use this
import { Transporter } from 'nodemailer';
@Module({
imports: [MailerModule.forRoot({ ... })],
exports: [MailerModule],
})
class CustomMailerModule implements OnModuleDestroy {
constructor(
@Inject(MailerService)
private readonly mailerService: MailerService,
) {}
async onModuleDestroy() {
(this.mailerService['transporter'] as Transporter).close();
}
}
Hello,
I am using a module to send email. So I installed the module @nestjs-modules/mailer and then I make my config to send mail.
But the things are I want to test if I put the good credential and SMTP host. In node mailer there is a function transporter. Verify() that verify if the information is correct.
But in the mailService I can't access to the transporter.
mailer.service.d.ts in the @nestjs-modules/mailer export declare class MailerService { private readonly mailerOptions; private readonly transportFactory; private transporter; private transporters; private templateAdapter; private initTemplateAdapter; constructor(mailerOptions: MailerOptions, transportFactory: IMailerTransportFactory); sendMail(sendMailOptions: ISendMailOptions): Promise;
addTransporter(transporterName: string, config: string | smtpTransport | smtpTransport.Options): string;
}
I don't know if there is another solution, but for me, it's will be nice to have the transporter in public? Like this I could test if my email information is correct