@shubuzuo/nestjs-email

对项目中 第三方 邮箱服务 进行包装

Usage no npm install needed!

<script type="module">
  import shubuzuoNestjsEmail from 'https://cdn.skypack.dev/@shubuzuo/nestjs-email';
</script>

README

nest-email email 封装

注意:仍在开发中,目前仅在内部使用
Nest框架 短信服务 插件

使用说明

外部人员仅供参考,请不要用于生产环境,因此导致的事故后果请自行承担。

安装

$ npm i @shubuzuo/nestjs-email

or

$ yarn add @shubuzuo/nestjs-email 

用法

config.js ??

export const config = {
    "ApiKeyPublic": "-------",
  "ApiKeyPrivate": "-------"
};

module.ts

import { AppController } from './test.controller';
import { EmailModule } from '@shubuzuo/nestjs-email';

const config = {
                apiKey: '-------------------',
                apiSecret: '-----------------------'
              }

@Module({
    imports: [ 
        EmailModule.forRoot(config)
    ],
    controllers: [AppController],
})

export class AppModule{}

controller.ts

import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
import { EmailService } from '@shubuzuo/nestjs-email';

@Controller()
export class AppController {
  constructor(
    private readonly emailService: EmailService
  ) {}

  @Get('email')
  async setEmali(): Promise<any> {

    await this.emailService.send(
      // 此项 马上 加入 配置项 和key一起配置
      {
        Email: '邮箱地址',
        Name: '邮箱名字'
      },
      {
        emailAddress: '目的邮箱地址',
        name: '邮件名字'
      },
      {
        subject: '副标题',
        text: '文本',
        html: `html 片段`
      }
    )
  }
}