verifyEmail.js 855 B

123456789101112131415161718192021222324252627282930
  1. import config from "config";
  2. import mail from "../index";
  3. /**
  4. * Sends a verify email 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 email reset 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: config.get("mail.from"),
  14. to,
  15. subject: "Please verify your email",
  16. html: `
  17. Hello there ${username},
  18. <br>
  19. <br>
  20. To verify your email, please visit <a href="${config.get("serverDomain")}/auth/verify_email?code=${code}">${config.get(
  21. "serverDomain"
  22. )}/auth/verify_email?code=${code}</a>.
  23. `
  24. };
  25. mail.runJob("SEND_MAIL", { data })
  26. .then(() => cb())
  27. .catch(err => cb(err));
  28. };