How to use the keystone.Email function in keystone

To help you get started, we’ve selected a few keystone examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JedWatson / keystone-forum / models / User.js View on Github external
user.save(function(err) {
		
		if (err) return next(err);
				
		// send email
		new keystone.Email('reset-password').send({
			user: user,
			link: '/reset-password/' + user.resetPasswordKey,
			subject: 'Reset your password on KeystoneJS Forum',
			baseURL: req.protocol + '://' + req.get('host'),
			to: user.email,
			from: {
				name: 'KeystoneJS Forum',
				email: 'forum@keystonejs.com'
			}
		}, next);
		
	});
github JedWatson / keystone-forum / models / User.js View on Github external
user.save(function(err) {
		
		if (err) return next(err);
				
		// send email
		new keystone.Email('verify-email').send({
			user: user,
			link: '/auth/verify/?email=' + user.email + '&key=' + user.emailVerificationKey,
			subject: 'Please confirm your email address',
			baseURL: req.protocol + '://' + req.get('host'),
			to: user.email,
			from: {
				name: 'KeystoneJS Forum',
				email: 'forum@keystonejs.com'
			}
		}, next);
		
	});
github keystonejs / keystone-test-project / tests / email / index.js View on Github external
var mailgunDomain = process.env.MAILGUN_DOMAIN;
var mandrillApiKey = process.env.MANDRILL_API_KEY;

if (!mandrillApiKey && (!mailgunApiKey || !mailgunDomain)) {
	throw Error('You must provide either or both Mailgun or Mandrill auth');
}

var keystone = require('keystone');
keystone.set('emails', './templates');

if (mailgunApiKey) {
	keystone.set('email transport', 'mailgun');
	keystone.set('mailgun api key', mailgunApiKey);
	keystone.set('mailgun domain', mailgunDomain);

	new keystone.Email(template).send({}, {
		to: to,
		from: {
			name: 'Keystone Test Project',
			email: 'test@keystonejs.com',
		},
		subject: 'Keystone Test Email!',
	}, function (err, result) {
		if (err) {
			console.error('🤕 Mailgun test failed with error:\n', err);
		} else {
			console.log('📬 Successfully sent Mailgun test with result:\n', result);
		}
	});
}

if (mandrillApiKey) {
github keystonejs / keystone-test-project / tests / email / index.js View on Github external
email: 'test@keystonejs.com',
		},
		subject: 'Keystone Test Email!',
	}, function (err, result) {
		if (err) {
			console.error('🤕 Mailgun test failed with error:\n', err);
		} else {
			console.log('📬 Successfully sent Mailgun test with result:\n', result);
		}
	});
}

if (mandrillApiKey) {
	keystone.set('mandrill api key', mandrillApiKey);

	new keystone.Email({
		templateName: template,
		templateExt: 'pug',
		transport: 'mandrill',
	}).send({}, {
		to: [to],
		from: {
			name: 'Keystone Test Project',
			email: 'test@keystonejs.com',
		},
		subject: 'Keystone Test Email!',
	}, function (err, result) {
		if (err) {
			console.error('🤕 Mandrill test failed with error:\n', err);
		} else {
			console.log('📬 Successfully sent Mailgun test with result:\n', result);
		}
github JedWatson / keystone-forum / routes / dev / email.js View on Github external
switch (req.params.key) {

		case 'forgotten-password':
			
			var email = new keystone.Email('forgotten-password');
			
			email.render({
				subject: 'Forgotten Password',
			}, renderCallback);
			
		break;

		case 'new-reply':
			
			var email = new keystone.Email('new-reply');
			
			loadReply(function() {
				email.render({
					subject: 'KeystoneJS reply',
					reply: data.reply,
					topic: { name: 'Testing email notifications on replies' }
				}, renderCallback);
			});
			
		break;

		default:
			res.status(404).render('404', { req: req, env: process.env.NODE_ENV });
	}
	
}
github JedWatson / keystone-forum / routes / dev / email.js View on Github external
.where('state', 'published')
			.sort('-createdAt')
			.exec(function(err, reply) {
				
				data.reply = reply;
				callback();
				
			});
	}
	
	
	switch (req.params.key) {

		case 'forgotten-password':
			
			var email = new keystone.Email('forgotten-password');
			
			email.render({
				subject: 'Forgotten Password',
			}, renderCallback);
			
		break;

		case 'new-reply':
			
			var email = new keystone.Email('new-reply');
			
			loadReply(function() {
				email.render({
					subject: 'KeystoneJS reply',
					reply: data.reply,
					topic: { name: 'Testing email notifications on replies' }
github JedWatson / keystone-forum / models / Topic.js View on Github external
subscribers.forEach(function(subscriber) {
				new keystone.Email('new-topic').send({
					subject: 'New topic: ' + topic.name,
					topic: topic,
					baseURL: req.protocol + '://' + req.get('host'),
					to: subscriber.email,
					from: {
						name: 'KeystoneJS Forum',
						email: 'forum@keystonejs.com'
					}
				}, next);
			});
		}
github JedWatson / keystone-forum / models / Reply.js View on Github external
topic.watchedBy.forEach(function(watcher) {
			new keystone.Email('new-reply').send({
				subject: 'Re: ' + topic.name,
				topic: topic,
				reply: reply,
				baseURL: req.protocol + '://' + req.get('host'),
				to: watcher.email,
				from: {
					name: data.author.name.full,
					email: 'forum@keystonejs.com'
				}
			}, next);
		});
	});