verifyEmail.js 935 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import config from "config";
  2. // const moduleManager = require('../../../index');
  3. import mail from "../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. export default (to, username, code, cb) => {
  13. const data = {
  14. from: "Musare <noreply@musare.com>",
  15. 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("serverDomain")}/auth/verify_email?code=${code}">${config.get(
  22. "serverDomain"
  23. )}/auth/verify_email?code=${code}</a>.
  24. `
  25. };
  26. mail.runJob("SEND_MAIL", { data })
  27. .then(() => {
  28. cb();
  29. })
  30. .catch(err => {
  31. cb(err);
  32. });
  33. };