Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template issue #72

Open
Romkin7 opened this issue Feb 23, 2018 · 2 comments
Open

Template issue #72

Romkin7 opened this issue Feb 23, 2018 · 2 comments
Labels

Comments

@Romkin7
Copy link

Romkin7 commented Feb 23, 2018

I made template and gave all parameters it neede to send it.
but i'm receiving this error all the time:

Error: ENOENT: no such file or directory, open '../../views/email/verifyemail.ejs'
here is my code:
"use strict";
const crypto = require('crypto');
const nodemailer = require('nodemailer');
const mg = require('nodemailer-mailgun-transport');
const ejs = require('ejs');
const auth = {
	auth: {
		api_key: process.env.MAILGUN_API_KEY,
		domain: 'sandbox5454645445454545465656565.mailgun.org'
	}
};
const nodemailerMailgun = nodemailer.createTransport(mg(auth));
 //Send email to request email confirmation
module.exports.sendActivationEmail = (req, res, user, next) => {
	let token = crypto.randomBytes(20).toString("hex");
 	let contextObject = {
  		user: user,
  		token: token
	};
 		nodemailerMailgun.sendMail({
  		from: 'user 1 <testemail@gmail.com>',
  		to: user.email, // An array if you have multiple recipients.
  		subject: 'verify email',
  		template: {
    		name: '../../views/email/verifyemail.ejs',
    		engine: 'ejs',
    		context: contextObject
  		}
	}, function (err, info) {
  		if (err) {
    		console.log('Error: ' + err);
    		return next();
  		} else {
    		console.log('Response: ' + info);
    		next();
  		}
	});
};

I really don't know where should this verifyemail.ejs file be located so it can be found and sent out.
Cheers, Roman T

@jmcdo29
Copy link

jmcdo29 commented May 30, 2018

Did you ever figure this out? I'm having a problem with the same thing right now.

EDIT: I was forgetting to add the path "views" to my file. To anyone coming to this looking for help the name of your files should resemble "views/fileNameHere.filetype"

@francoism90
Copy link

Just for the record, if <root>/views/.. is your templates path, use this as name, e.g.:

name: `views/${template}.pug`,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants