email.js
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const router = require('koa-router')()
var status = require('../util/resTemplate')
const emailUtil = require('../util/emailUtil')
const sendMessageUtil = require('../util/sendMessageUtil')
router.prefix('/email')
router.post('/sendEmail', async (ctx, next) => {
try{
var body = ctx.request.body;
//邮件地址、用户名、手机号、公司名称、座机和客户端ip
let back = await emailUtil.sendMail(body.Email,null, body.userName+body.phone+body.company+body.landline+body.ip)
ctx.response.status= 200;
ctx.response.body= {
msg:'发送成功'
};
}catch(e){
console.error(e)
status.catchError(ctx,400,e.message);
}
})
router.post('/sendMessage', async (ctx, next) => {
try{
var body = ctx.request.body;
let back = await sendMessageUtil.sendMessage(body.Email,null, body.userName+body.phone+body.company+body.landline+body.ip)
ctx.response.status= 200;
ctx.response.body= {
msg:'发送成功'
};
}catch(e){
console.error(e)
status.catchError(ctx,400,e.message);
}
})
module.exports = router;