passwordRequest.js 976 B

123456789101112131415161718192021222324252627282930313233343536
  1. // const moduleManager = require('../../../index');
  2. import mail from "../index";
  3. /**
  4. * Sends a request password email
  5. *
  6. * @param {string} to - the email address of the recipient
  7. * @param {string} username - the username of the recipient
  8. * @param {string} code - the password code of the recipient
  9. * @param {Function} cb - gets called when an error occurred or when the operation was successful
  10. */
  11. export default (to, username, code, cb) => {
  12. const data = {
  13. from: "Musare <noreply@musare.com>",
  14. to,
  15. subject: "Password request",
  16. html: `
  17. Hello there ${username},
  18. <br>
  19. <br>
  20. Someone has requested to add a password to your account. If this was not you, you can ignore this email.
  21. <br>
  22. <br>
  23. 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.
  24. `
  25. };
  26. mail.runJob("SEND_MAIL", { data })
  27. .then(() => {
  28. cb();
  29. })
  30. .catch(err => {
  31. cb(err);
  32. });
  33. };