passwordRequest.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. const config = require("config");
  2. // const moduleManager = require('../../../index');
  3. const mail = require("../index");
  4. /**
  5. * Sends a request password email
  6. *
  7. * @param {String} to - the email address of the recipient
  8. * @param {String} username - the username of the recipient
  9. * @param {String} code - the password code of the recipient
  10. * @param {Function} cb - gets called when an error occurred or when the operation was successful
  11. */
  12. module.exports = function(to, username, code, cb) {
  13. let data = {
  14. from: "Musare <noreply@musare.com>",
  15. to: to,
  16. subject: "Password request",
  17. html: `
  18. Hello there ${username},
  19. <br>
  20. <br>
  21. Someone has requested to add a password to your account. If this was not you, you can ignore this email.
  22. <br>
  23. <br>
  24. The code is <b>${code}</b>. You can enter this code on the page you requested the password on. This code will expire in 24 hours.
  25. `
  26. };
  27. mail.runJob("SEND_MAIL", { data })
  28. .then(() => {
  29. cb();
  30. })
  31. .catch(err => {
  32. cb(err);
  33. });
  34. };