email.js 728 字节
const router = require('koa-router')()
var status = require('../util/resTemplate') 
const emailUtil = require('../util/emailUtil')

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);    
      } 
  })

  module.exports = router;