Leccho
Leccho

Reputation: 666

NestJs Mailer Module error upon sending email

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://[email protected]:[email protected]',
      defaults: {
        from:'"nest-modules" <[email protected]>',
      },
      template: {
        dir: __dirname + '/templates',
        adapter: new HandlebarsAdapter(),
        options: {
          strict: true,
        },
      },
    }),
  ],
})
export class AppModule {}

sending the email:

        this.mailerService.sendMail({
            to: '[email protected]',
            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');
        });

Upvotes: 4

Views: 3429

Answers (1)

Leccho
Leccho

Reputation: 666

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

Upvotes: 3

Related Questions