verifyEmail.js 819 B

123456789101112131415161718192021222324252627
  1. const config = require('config');
  2. const mail = require('../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. module.exports = function(to, username, code, cb) {
  12. let data = {
  13. from: 'Musare <noreply@musare.com>',
  14. to: to,
  15. subject: 'Please verify your email',
  16. html:
  17. `
  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('serverDomain')}/auth/verify_email?code=${code}</a>.
  22. `
  23. };
  24. mail.sendMail(data, cb);
  25. };