import request from 'request' import logger from '../logger/Logger' import config from '../config/Config' export class MailRequest { title: string content: string constructor(title: string, content: string) { this.title = title this.content = content } } export default class MailUtil { static send(req: MailRequest) { let params = { "topic": "DailyOperation", "sender_name": req.title, "title": req.title, "content": req.content } request({ url: `http://${config["maintainmail"]}/sendmessage`, method: 'POST', json: true, body: params }, (err, resp, data) => { if (err) { logger.info("邮件发送失败", err, req.content) } else { logger.info(data) logger.info("邮件发送成功", req.content) } }) } }