2020-09-18 16:04:40 +08:00
|
|
|
|
2023-11-02 10:43:34 +08:00
|
|
|
![downloads](https://img.shields.io/npm/dt/@gm5/mail.svg)
|
|
|
|
![version](https://img.shields.io/npm/v/@gm5/mail.svg)
|
2020-09-18 16:04:40 +08:00
|
|
|
|
2023-11-02 10:43:34 +08:00
|
|
|
# @gm5/mail
|
|
|
|
|
|
|
|
> 一个简单的邮件发送模块, 可用于发送系统邮件, 如注册验证等。
|
2020-09-18 16:04:40 +08:00
|
|
|
|
|
|
|
## 安装
|
|
|
|
|
|
|
|
```bash
|
2023-11-02 10:43:34 +08:00
|
|
|
npm i @gm5/mail
|
2020-09-18 16:04:40 +08:00
|
|
|
```
|
|
|
|
|
2023-11-02 10:43:34 +08:00
|
|
|
## 使用
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
|
|
|
import { createApp } from '@gm5/code'
|
|
|
|
import { MailModule } from '@gm5/mail'
|
|
|
|
|
|
|
|
var app = createApp()
|
|
|
|
|
|
|
|
app.install(MailModule, {
|
|
|
|
auth: {
|
|
|
|
user: 'example@example.com',
|
|
|
|
username: 'example',
|
|
|
|
pass: '123456'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.run()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// in controller
|
|
|
|
|
|
|
|
this.context.$$mail
|
|
|
|
.to('tom@xx.com', 'tom')
|
|
|
|
.send({
|
|
|
|
subject: 'hello',
|
|
|
|
text: 'how are you?',
|
|
|
|
html: '<p>how are you?</p>'
|
|
|
|
})
|
|
|
|
|
|
|
|
```
|