# This is Email Factory 1. There provide all about email service such as: - [x] POST request to send email to target receivers - [x] Receive argument of multiple target receivers - [ ] Select sender when request - [x] Receive argument of contents - [x] Select template when request - [x] Template store as assets in ./assets/template/\* --- # How to use 1. Template: - Template save in ./assets/template/ and use ejs. - If you want to add template, please use the directory. - About argument: a. "locals" can include all argument , it is a json. b. When you use the template, you will call mailerService.sendMail(sendMailOptions),and in 'sendMailOptions' have a attribute "content", that is "locals": ```TS const sendMailOptions: ISendMailOptions = { to: data.receiver, subject: data.subject || '用户邮箱验证', template: 'test.ejs', context: { date, //日期 text:data.text, } }; ``` c. This is use "locals" example: ```EJS
<%= locals.text %> (If the text same as your input, then i am health)
``` _Tips: ❌ locals.context.text ✅ locals.text_ More : https://ejs.bootcss.com/#docs 2. Config - Sender account in ./assets/sender.ts 3. API - Controller in /src/app.controller.ts, because this is a simple email service, so just three api to use. If the function to be more, may be will to rebuild file structure - Service in /src/app.service.ts, and just have one send email service. - The microsServer will not have anything about database. - Still don't have any api for microsServer use, because gateway still is a baby.I will create microsServer api after gateway done. > Tips: > > In ./src/email.module.ts you can open the preview email config, it really useful but > remember close it when you finish the email style adjust.Because it will prevent send email > active. # Todo - Transform be microservice - Turn the transport from http to tcp - Register in gateway # Current API Tips: it no real use in project, just listing the service should to do. Base URLs: https://localhost:12500 # Email ## POST /email/test POST /email/test > Body 请求参数 ```json { "content": "string", "subject": "string", "template": "string", "receiver": "string" } ``` ### 请求参数 | 名称 | 位置 | 类型 | 必选 | 说明 | | ---- | ---- | ----------------------------------------- | ---- | ---- | | body | body | [SingleEmailBody](#schemasingleemailbody) | 否 | none | > 返回示例 > 201 Response ```json {} ``` ### 返回结果 | 状态码 | 状态码含义 | 说明 | 数据模型 | | ------ | ------------------------------------------------------------ | ---- | -------- | | 201 | [Created](https://tools.ietf.org/html/rfc7231#section-6.3.2) | 成功 | Inline | ### 返回数据结构 ## POST /email/single POST /email/single > Body 请求参数 ```json { "content": "string", "subject": "string", "template": "string", "receiver": "string" } ``` ### 请求参数 | 名称 | 位置 | 类型 | 必选 | 说明 | | ---- | ---- | ----------------------------------------- | ---- | ---- | | body | body | [SingleEmailBody](#schemasingleemailbody) | 否 | none | > 返回示例 > 201 Response ```json {} ``` ### 返回结果 | 状态码 | 状态码含义 | 说明 | 数据模型 | | ------ | ------------------------------------------------------------ | ---- | -------- | | 201 | [Created](https://tools.ietf.org/html/rfc7231#section-6.3.2) | 成功 | Inline | ### 返回数据结构 ## POST /email/multiple POST /email/multiple > Body 请求参数 ```json { "content": "string", "subject": "string", "template": "string", "receiver": ["string"] } ``` ### 请求参数 | 名称 | 位置 | 类型 | 必选 | 说明 | | ---- | ---- | --------------------------------------------- | ---- | ---- | | body | body | [MultipleEmailBody](#schemamultipleemailbody) | 否 | none | > 返回示例 > 201 Response ```json {} ``` ### 返回结果 | 状态码 | 状态码含义 | 说明 | 数据模型 | | ------ | ------------------------------------------------------------ | ---- | -------- | | 201 | [Created](https://tools.ietf.org/html/rfc7231#section-6.3.2) | 成功 | Inline | ### 返回数据结构 ## GET /email GET /email > 返回示例 > 200 Response ```json {} ``` ### 返回结果 | 状态码 | 状态码含义 | 说明 | 数据模型 | | ------ | ------------------------------------------------------- | ---- | -------- | | 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | 成功 | Inline | ### 返回数据结构 ## GET /email/hi GET /email/hi > 返回示例 > 200 Response ```json {} ``` ### 返回结果 | 状态码 | 状态码含义 | 说明 | 数据模型 | | ------ | ------------------------------------------------------- | ---- | -------- | | 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | 成功 | Inline | ### 返回数据结构 # 数据模型