Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var nodemailer=require('nodemailer');
- var sgTransporter = require('nodemailer-sendgrid-transport');
- var options={
- auth: {
- api_user: "xxx",
- api_pass: "xxx"
- }
- };
- var client = nodemailer.createTransport(sgTransporter(options));
- var sendMail=function(emailTo, subject, html, fn){
- var mailOptions={
- from:'xxx',
- to:emailTo,
- subject:subject,
- html:html
- };
- client.sendMail(mailOptions, function(error, response){
- if(error){
- console.log(error);
- fn(error);
- }
- else{
- console.log("Message sent: " + response.message);
- fn(response);
- }
- });
- };
- router.get('/verifyEmail', function(req,res){
- if(req.isAuthenticated()) {
- var subject='Verify your email address';
- var link="https://grovemonitor-jamesokbo.c9users.io/verify/:"+req.user._id;
- var html='Hello,<br> Please Click on the link to verify your Account.<br><a href='+link+'>Click here to verify</a>';
- console.log('Sending verification email to: '+req.user.email);
- sendMail(req.user.email,subject, html,function(error, response){
- if (error){
- return res.status(400).json({error:error});
- }
- return res.status(200).json(response);
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement