resetPwd.js 935 B

12345678910111213141516171819202122232425262728
  1. const _ = require('lodash');
  2. const assert = require('assert');
  3. /**
  4. * 重置密码
  5. * @param {Object} sender 发送人设置
  6. * @param {String} receiver 发送对象
  7. * @param {Object} params 模板参数
  8. */
  9. module.exports = (sender, receiver, params) => {
  10. assert(sender, '缺少发送人信息');
  11. const { from, user, pass } = sender;
  12. const auth = { user, pass };
  13. const mailConfig = {
  14. host: 'smtp.163.com',
  15. port: 465,
  16. secure: true,
  17. auth,
  18. };
  19. const { password } = params;
  20. const text = `【重置密码】密码重置成功! 您的新密码为:${password},若非本人操作,请忽略此信息。<${from}>`;
  21. const mailContext = {
  22. from: `"${from}" <${user}>`, // 邮件来源
  23. to: receiver, // 邮件发送到哪里,多个邮箱使用逗号隔开
  24. subject: `${from}-重置密码`, // 邮件主题
  25. html: text, // html类型的邮件正文
  26. };
  27. return { mailContext, mailConfig };
  28. };