首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >发送电子邮件时出现NestJs Mailer模块错误

发送电子邮件时出现NestJs Mailer模块错误
EN

Stack Overflow用户
提问于 2020-07-20 23:24:41
回答 1查看 748关注 0票数 4

我使用的是NestJs Mailer Module,最新的稳定版本。您可以找到文档here

我已经搜索了这个错误的解决方案,但我什么也没找到:

代码语言:javascript
复制
Error: self signed certificate in certificate chain

app.module.ts:

代码语言:javascript
复制
@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 {}

发送电子邮件:

代码语言:javascript
复制
        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');
        });
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-01-15 01:32:29

作为解决方案,您可以在传输选项中使用tls: { rejectUnauthorized: false }

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62998727

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档