NestJs Mailer Module error upon sending email

Viewed 1203

I'm using NestJs Mailer Module, the latest stable version. You can find the documentation here.

I've search a solution for this error but I found nothing:

Error: self signed certificate in certificate chain

app.module.ts:

@Module({
  imports: [
    MailerModule.forRoot({
      transport: 'smtps://user@domain.com:pass@smtp.domain.com',
      defaults: {
        from:'"nest-modules" <modules@nestjs.com>',
      },
      template: {
        dir: __dirname + '/templates',
        adapter: new HandlebarsAdapter(),
        options: {
          strict: true,
        },
      },
    }),
  ],
})
export class AppModule {}

sending the email:

        this.mailerService.sendMail({
            to: 'example@domain.com',
            subject: 'subject'
            text: 'blahblahblah'
            html: 'blahblahblah'
        }).then(() => {
            this.logger.log('Error email sent!', 'HttpExceptionFilter');
        }).catch(err => {
            this.logger.error('Error while sending error email.', err, 'HttpExceptionFilter');
        });
1 Answers

As a solution, you can use tls: { rejectUnauthorized: false } in your transport options.

Related