verifyEmail.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. const config = require("config");
  2. // const moduleManager = require('../../../index');
  3. const mail = require("../index");
  4. /**
  5. * Sends a verify email 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 email reset 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: "Please verify your email",
  17. html: `
  18. Hello there ${username},
  19. <br>
  20. <br>
  21. To verify your email, please visit <a href="${config.get(
  22. "serverDomain"
  23. )}/auth/verify_email?code=${code}">${config.get(
  24. "serverDomain"
  25. )}/auth/verify_email?code=${code}</a>.
  26. `
  27. };
  28. mail.runJob("SEND_MAIL", { data })
  29. .then(() => {
  30. cb();
  31. })
  32. .catch(err => {
  33. cb(err);
  34. });
  35. };