All files / koa/libs mail.js

27.27% Statements 3/11
0% Branches 0/2
0% Functions 0/3
27.27% Lines 3/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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    3x   3x                 3x                                    
'use strict'
 
const nodemailer = require('nodemailer');
 
var transporter = nodemailer.createTransport({
  host: 'smtp.exmail.qq.com',
  auth: {
    user: 'info@xxx-xxxx.com',
    pass: 'xx',
  },
  port: 465,
});
 
exports.sendMail = (doc) => {
  return new Promise(function (resolve, reject) {
    let mailOptions = {
      from: '"info" <info@xx-xxx.com>',
      to: doc.to,
      subject: doc.subject,
      text: doc.desc,
      html: doc.content,
    };
    transporter.sendMail(mailOptions, (error, info) => {
      if (error) {
        console.log(error);
        reject(error)
      }
      console.log('Message %s sent: %s', info.messageId, info.response);
      resolve('ok')
    });
  });
}