Beispiel #1
0
  signupEmail: function(username){
    var options = {
      // auth: {
      //   api_user: 
      //   api_key: 
      // }
    };

    var mailer = nodemailer.createTransport(sgTransport(options));

    var email = {
      from: '"Marco Polo" <*****@*****.**>',
      to: username,
      subject: 'Welcome to Trip Planner',
      text: 'Be prepared to get shit done so you can then relax and have some fun',
      html: '<b>Be prepared to get shit done so you can then relax and have some fun</b>'
    };

    mailer.sendMail(email, function(err, res){
        if (err ){
          console.log(error);
        }
        else {
          console.log('Message sent: ' , res);
        }
    });
  },
Beispiel #2
0
        function (token, user, done) {
            var options = {
                auth: {
                    api_user: secrets.smtpuser,
                    api_key: secrets.smtppassword
                }
            };
            var mailer = nodemailer.createTransport(sgTransport(options));

            var email = {
                from: 'noreply@' + secrets.company + '.com',
                to: user.email,
                subject: 'Welcome to ' + secrets.company + ', please confirm your account',
                text: 'Confirming your account will allow you to log in and all future notifications will be sent to this email address.\n\n' +
                'Please visit the following url:\n\n' +
                'http://' + req.headers.host + '/confirm/' + token + '\n'
            };

            mailer.sendMail(email, function (err) {
                if (err) {
                    console.log(err);
                }
                done('An e-mail has been sent to ' + user.email + ' with instructions to activate the account.');
            });
        }
Beispiel #3
0
function sendmail (emailID) {
  var options = {
    auth: {
      api_user: '******',
      api_key: 'num1world'
    }
  }

  var client = nodemailer.createTransport(sgTransport(options));
    var email = {
      from: '*****@*****.**',
      to: emailID,
      subject: 'MVDECA Confirmation',
      text: 'Congrats you are now a member of MVDECA. If you are having any issues logging in, contact an officer',
      html: '<b>Congrats you are now a member of MVDECA. If you are having any issues logging in, contact an officer.</b>'
    };

    client.sendMail(email, function(err, info){
        if (err ){
          console.log(error);
        }
        else {
          console.log('Message sent: ' + info.response);
        }
    });
}
Beispiel #4
0
        user.save(function (err) {
            if (err) {
                return res.status(409).send(err).end();
            }


            var options = {
                auth: {
                    api_user: secrets.smtpuser,
                    api_key: secrets.smtppassword
                }
            };
            var mailer = nodemailer.createTransport(sgTransport(options));

            var email = {
                from: 'noreply@' + secrets.company + '.com',
                to: user.email,
                subject: 'Your password has been changed',
                text: 'Hello,\n\n' +
                'This is a confirmation that the password for your account ' + user.email + ' has just been changed.\n'
            };

            mailer.sendMail(email, function (err) {
                if (err) {
                    console.log(err);
                }
                res.status(200).send("Your password has been changed.").end();
            });

        });
Beispiel #5
0
        function (token, user, done) {
            var options = {
                auth: {
                    api_user: secrets.smtpuser,
                    api_key: secrets.smtppassword
                }
            };
            var mailer = nodemailer.createTransport(sgTransport(options));

            var email = {
                from: 'noreply@' + secrets.company + '.com',
                to: user.email,
                subject: 'Password Reset Request',
                text: 'You are receiving this message because you (or someone else) have requested the reset of the password for your account.\n\n' +
                'Please click on the following link, or paste this into your browser to complete the process:\n\n' +
                'http://' + req.headers.host + '/reset/' + token + '\n\n' +
                'If you did not request this, please ignore this email and your password will remain unchanged.\n'
            };

            mailer.sendMail(email, function (err) {
                if (err) {
                    console.log(err);
                }
                done('An e-mail has been sent to ' + user.email + ' with further instructions.');
            });
        }
 }, function (error, emailBody) {
   if(error) {
     console.log(error);
     return res.status(500).jsonp({message: 'Could not register user.'});
   }
   if(config.env !== 'test') {
     var transport = nodemailer.createTransport(sgTransport({
       auth: {
         api_user: config.email.accounts.sendgrid.username,
         api_key: config.email.accounts.sendgrid.password
       }
     }));
     transport.sendMail({
       from: config.email.accounts.info,
       to: email,
       subject: isAdmin ? 'New Admin Account' : 'New Account',
       html: emailBody
     }, function (error, reply) {
       if(error) {
         console.log(error);
       }
       console.log('Register user email sent for email '+ email + ' with email server reply of ' + reply.message);
     });
   }
   utils.insert(utils.users, userId, userSchema, function (error) {
     if(error) {
       console.log(error);
       return res.status(500).jsonp({message: 'Could not register user.'});
     }
     return res.jsonp({message: 'Registered, please check your email to activate your account.'});
   });
 });
Beispiel #7
0
  reminderEmail: function(username){
    var options = {
      auth: {
        // api_user:
        // api_key: 
      }
    };

    var mailer = nodemailer.createTransport(sgTransport(options));

    var email = {
      from: '"Marco Polo" <*****@*****.**>',
      to: username,
      subject: 'Reminder: Booking',
      text: 'Get your things booked.',
      html: '<b>Get your things booked.</b>'
    };

    console.log('look here', email.to)
    mailer.sendMail(email, function(err, res){
      if (err ){
        console.log(error);
      } else {
        console.log('Message sent: ' , res);
      }
    });
  }
  return (email, done) => {
    let transport
    if (process.env.NODE_ENV === 'production') {
      if (!config.host) {
        transport = sgTransport({
          auth: {
            api_key: config.apiKey
          }
        })
      } else {
        transport = {
          host: config.host,
          port: config.port
        }
      }
    } else {
      transport = {
        host: 'debugmail.io',
        port: 25,
        auth: {
          user: process.env.DEV_MAIL_USER || '',
          pass: process.env.DEV_MAIL_PASS || ''
        }
      }
    }

    const mailer = nodemailer.createTransport(transport)

    mailer.sendMail(email, done)
  }
			}, function(err, clientEmailHTML) {

				var emailSubject = 'Studio Center Auditions - Client Login Information';

				var transporter = nodemailer.createTransport(sgTransport(config.mailer.options));

				var mailOptions = {
					to: user.email,
					from: adminEmail || config.mailer.from,
					replyTo: adminEmail || config.mailer.from,
					cc: config.mailer.notifications,
					subject: emailSubject,
					html: clientEmailHTML
				};

				transporter.sendMail(mailOptions, function(){

					// write change to log
					var log = {
						type: 'system',
						sharedKey: String(user._id),
						description: 'user ' + user.displayName + ' added and emailed ',
						user: user
					};
					log = new Log(log);
					log.save();

				});

			});
Beispiel #10
0
function sendContactEmail(data, res){
    // create the nodemailer
    var client = nodemailer.createTransport(sgTransport({
        auth: {
          api_key: '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'
        }
    }));

    var mailOptions = {
        to: '*****@*****.**',
        from: data.email,
        subject:  data.name+" interested in: \n "+data.subject,
        html: '<b>You have a new contact from your website</b><br /><p>'+data.message
    };
    //send
    client.sendMail(mailOptions, function(err, info) {
        //re-render contact page with message
        var message = null;
        if(err){
            message = "An error has occured " + err;
            console.log(err);
        } else {
            res.send(true)
            message = "Email has been sent!";
            console.log('Message sent: ' + info.response);
        }
        res.redirect('/');
    });
}
Beispiel #11
0
 function (user, done) {
     var options = {
         auth: {
             api_key: apiKey
         }
     };
     var mailer = nodemailer.createTransport(sgTransport(options));
     var templatePath = 'views/emails/password.jade';
     var jadeOptions = {globals:[{user:user}]};
     var html = jade.renderFile(templatePath, jadeOptions);
     var email = {
         to: user.local.email,
         from: fromEmail,
         subject: 'Your password has been changed',
         text: 'Hello,\n\n' +
         'This is a confirmation that the password for your account ' + user.local.email + ' has just been changed.\n',
         html: html
     };
     mailer.sendMail(email, function (err, res) {
         if(err){
             return console.log(err);
         }
         console.log('Message sent: ' + res);
         req.flash('success', 'Success! Your password has been changed.');
         done(err);
     });
     req.flash('error', user.changePassword);
 }
Beispiel #12
0
 function (token, user, done) {
     var options = {
         auth: {
             api_key: apiKey
         }
     };
     var mailer = nodemailer.createTransport(sgTransport(options));
     var templatePath = 'views/emails/forgot.jade';
     var jadeOptions = {globals:[{host:req.headers.host,token:token}]};
     var html = jade.renderFile(templatePath, jadeOptions);
     var email = {
         to: user.local.email,
         from: fromEmail,
         subject: 'User Password reset request',
         text: 'You are receiving this because you (or someone else) have requested the reset of the password for your account.\n\n' +
         'Please click on the following link, or paste this into your browser to complete the process:\n\n' +
         'http://' + req.headers.host + '/reset/' + token + '\n\n' +
         'If you did not request this, please ignore this email and your password will remain unchanged.\n',
         html: html
     };
     mailer.sendMail(email, function (err, res) {
         if (err) {
             return console.log(err);
         }
         console.log('Message sent: ' + res);
         req.flash('info', 'An e-mail has been sent to ' + user.local.email + ' with further instructions.');
         done(err, 'done');
     });
 }
Beispiel #13
0
                            newUser.save(function (err) {
                                if (err)
                                    return done(err);

                                var sendgridOptions = {
                                    auth: {
                                        api_user: process.env.SENDGRID_USERNAME,
                                        api_key: process.env.SENDGRID_PASSWORD
                                    }
                                };

                                var mailer = nodemailer.createTransport(sgTransport(sendgridOptions));
                                
                                var email = {
                                    to: [newUser.facebook.email],
                                    from: '*****@*****.**',
                                    subject: 'Welcome to Vidcode',
                                    html: signUp
                                };

                                //dont send signgup emails until template is ready

                                mailer.sendMail(email, function (err) {
                                    if (err) {
                                        console.log(err);
                                    }
                                });

                                // we're not stopping if err so no callback
                                // log to console. Need some monitoring of errors for entire app
                                addUserToSendgridList(newUser.facebook.email, profile.displayName );

                                return done(null, newUser);
                            });
Beispiel #14
0
  signinEmail: function(username){
    var options = {
      auth: {
        // api_user: 
        // api_key: 
      }
    };

    var mailer = nodemailer.createTransport(sgTransport(options));

    var email = {
      from: '"Marco Polo" <*****@*****.**>',
      to: username,
      subject: 'Account Sign-in',
      text: 'Someone signed into your Trip Planner account....hope it was you.',
      html: '<b>Someone signed into your Trip Planner account....hope it was you.</b>'
    };

    mailer.sendMail(email, function(err, res){
      if (err ){
        console.log(error);
      } else {
        console.log('Message sent: ' , res);
      }
    });
  },
  constructor() {
    this.client = nodemailer.createTransport(sgTransport({
      auth: {
        api_key: process.env.SENDGRID_KEY
      }
    }));

    this.sendMessage = this.sendMessage.bind(this);
  }
Beispiel #16
0
function sendMail (email) {
  const mailer = nodemailer.createTransport(sgTransport(key()))

  mailer.sendMail(email, (err, res) => {
    if (err) { 
      console.log(err)
    }
    console.log(res)
  })
}
Beispiel #17
0
// params:
//  service (например Gmail или Yandex)
//  user
//  pass
//  mailTo
//  subj
//  text
function sendEmail(params, callback) {

    var transporter;

    if (params.service == "sendgrid") {

        var auth = {};
        if (process.env.SGKEY) {
            if (sendgridTransport)
                transporter = sendgridTransport;
            else {
                auth.api_key = process.env.SGKEY;
                transporter = nodemailer.createTransport(sgTransport({auth: auth}));
                sendgridTransport = transporter;
            }
        }
        else {
            auth.api_user = params.user;
            auth.api_key = params.pass;
            transporter = nodemailer.createTransport(sgTransport({auth: auth}));
        }
    }
    else {
        transporter = nodemailer.createTransport({
            service: params.service,
            auth: {
                user: params.user,
                pass: params.pass
            }
        });

    }
    transporter.sendMail({
        from: params.from,
        to: params.mailTo,
        subject: params.subj,
        text: params.text,
        html: params.html
    }, callback);
}
		// If valid email, send reset email using service
		function(emailHTML, user, done) {
			var smtpTransport = nodemailer.createTransport(sgTransport(config.mailer.options));
			var mailOptions = {
				to: user.email,
				from: config.mailer.from,
				subject: 'Your password has been changed',
				html: emailHTML
			};
			
			smtpTransport.sendMail(mailOptions, function(err) {
				done(err, 'done');
			});
		}
Beispiel #19
0
 app.post('/sendmail', function(req, res){
     var options = {
         auth: {
             api_key: process.env.EMAIL_TOKEN
         }
     }
     var mailer = nodemailer.createTransport(sgTransport(options));
     mailer.sendMail(req.body, function(error, info){
         if(error){
             res.status('401').json({err: info});
         }else{
             res.status('200').json({success: true});
         }
     });
 });
					}, function(err, clientEmailHTML) {

						var transporter = nodemailer.createTransport(sgTransport(config.mailer.options));

						var ccAddr = [config.mailer.notifications, adminEmail];

						// send email notification of update
						transporter.sendMail({
						    to: user.email,
							from: adminEmail || config.mailer.from,
							cc: ccAddr,
							replyTo: adminEmail || config.mailer.from,
						    subject: 'Studio Center Auditions - Client Information Updated',
						    html: clientEmailHTML
						});

					});
		// If valid email, send reset email using service
		function(emailHTML, user, done) {
			var smtpTransport = nodemailer.createTransport(sgTransport(config.mailer.options));
			var mailOptions = {
				to: user.email,
				from: config.mailer.from,
				subject: 'Password Reset',
				html: emailHTML
			};
			smtpTransport.sendMail(mailOptions, function(err) {
				if (!err) {
					res.send({
						message: 'An email has been sent to ' + user.email + ' with further instructions.'
					});
				}

				done(err);
			});
		}
 }, function (error, emailBody) {
   if(error) {
     console.log(error);
   }
   if(config.env !== 'test') {
     var transport = nodemailer.createTransport(sgTransport({
       auth: {
         api_user: config.email.accounts.sendgrid.username,
         api_key: config.email.accounts.sendgrid.password
       }
     }));
     transport.sendMail({
       from: config.email.accounts.info,
       to: user.email,
       subject: 'Update Profile',
       html: emailBody
     });
   }
 });
		// send Ken an email
		function(emailHTML, done) {

			var emailSubject = 'TALENT TERMINATED FROM VO ROSTER: ' + talent.name + ' ' + talent.lastName;

			// send email
			var transporter = nodemailer.createTransport(sgTransport(config.mailer.options));

			var mailOptions = {
								to: '*****@*****.**',
								from: req.user.email || config.mailer.from,
								replyTo: req.user.email || config.mailer.from,
								cc: config.mailer.notifications,
								subject: emailSubject,
								html: emailHTML
							};

			transporter.sendMail(mailOptions, function(err){
				done(err);
			});

		},
				// send Ken an email
				function(emailHTML, talentData, emailSig, done) {

					var emailSubject = 'NEW TALENT ADDITION TO VO ROSTER:  ' + talent.name + ' ' + talent.lastName;

					// send email
					var transporter = nodemailer.createTransport(sgTransport(config.mailer.options));

					var mailOptions = {
										to: ['*****@*****.**', '*****@*****.**'],
										from: req.user.email || config.mailer.from,
										replyTo: req.user.email || config.mailer.from,
										cc: config.mailer.notifications,
										subject: emailSubject,
										html: emailHTML
									};

					transporter.sendMail(mailOptions, function(err){
						done(err, talentData, emailSig );
					});

				},
Beispiel #25
0
	socket.on('contact-email', function (email)
	{
		var mailer = nodemailer.createTransport(sgTransport(
		{
			auth: { api_key: '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' }
		}));

		var mail = 
		{
			from    : email.address,
			to      : '*****@*****.**',
			subject : 'New message from LauraLeeWyatt.com',
			text    : 'Let\'s get together for coffee.' + '\n\n' + email.name + '\n' + email.address + '\n' + email.phone + '\n\n' + email.message
		};

		mailer.sendMail(mail, function (err, res) 
		{
			if (err) throw err;
			console.log(res);
		});
	});
 app.post('/contact', function(req, res) {
 	var data = {
 		email: req.body.email,
 		subject: req.body.subject,
 		message: req.body.message
 	};
 	console.log('TEstging ..... ');
 	console.log(data.email);
 	//create the nodemailer
 	var client = nodemailer.createTransport(sgTransport({
        auth: {
          api_user: '******',
          api_key: '<your password>'
        }
    }));
 	var mailOptions = {
        to: data.email,
        from: '*****@*****.**',
        subject: data.subject,
        text: data.message,
        html: '<b>Hello</b>'
    };
    //send
    client.sendMail(mailOptions, function(err, info) {
    	//re-render contact page with message
    	var message = null;
    	if(err){
    		message = "An error has occured " + err;
    		console.log(err);
    	} else {
    		message = "Email has been sent!";
    		console.log('Message sent: ' + info.response);
    	}
        req.flash('info', { msg: message});
        res.redirect('contact');
      });
 });
Beispiel #27
0
  var sendMessage = (emailResourceObject, done) => {
    if (!emailResourceObject) {
      return done(new Error('No recipient email address available'));
    }

    if (!process.env.PERSONAL_SERVER_SENDGRID_API_KEY) {
      return done(new Error('No SendGrid API key available'));
    }

    var email = {
      from: req.body.data.attributes['sender-email'],
      to: emailResourceObject.attributes['value'],
      subject: 'Message submitted to website',
      text: req.body.data.attributes['body']
    };

    debug('sending email', email);

    nodemailer.createTransport(sendGridTransport({
      auth: {
        api_key: process.env.PERSONAL_SERVER_SENDGRID_API_KEY
      }
    })).sendMail(email, done);
  };
Beispiel #28
0
var nodemailer = require('nodemailer');
var sgTransport = require('nodemailer-sendgrid-transport');
var config = require('../../config');
var sgOptions = {
  auth: {
    api_user: config.sgUsername,
    api_key: config.sgPassword
  }
};
var mailer = nodemailer.createTransport(sgTransport(sgOptions));

module.exports = {
  email: function(userData, emailAddress, callback) {
    var email = {
      to: emailAddress,
      from: '*****@*****.**',
      subject: 'Friend online!',
      text: 'One of your friends is playing steam.',
      html: '<h1>Awesome!</h1>'
    };
    mailer.sendMail(email, function(err, res) {
      if (err) {
        callback(err);
      } else {
        callback(null, res);
      }
    });
  }
};
	send: function(recipients, subject, body, cb) {
		logger.info(`Sending email to ${recipients} with subject ${subject}...`);
		logger.debug("Deprecated! libs/mailer is deprecated. Use Service.get('mailer') instead!");

		// recipients can be a comma separated string or array which will be sent by the 'to' field
		// recipients can also be an object with to, cc, bcc properties etc. See: 'Common fields' https://community.nodemailer.com/
		let emailRecipients = {}
		if (recipients instanceof Object) {
			if(recipients instanceof Array) {
				emailRecipients.to = recipients
			}
			else {
				emailRecipients = recipients
			}
		}
		else {
			emailRecipients.to = recipients
		} 

		let mailOptions = {
			from: config.mailer.from,
			to: emailRecipients.to,
			cc: emailRecipients.cc,
			bcc: emailRecipients.bcc,
			subject: subject,
			html: body
		};

		let transporter;
		if (config.mailer.transport == "smtp") {
			transporter = nodemailer.createTransport(config.mailer.smtp);
		}
		else if (config.mailer.transport == "mailgun") {
			let mg = require("nodemailer-mailgun-transport");
			transporter = nodemailer.createTransport(mg({
				auth: {
					api_key: config.mailer.mailgun.apiKey,
					domain: config.mailer.mailgun.domain
				}
			}));
		}
		else if (config.mailer.transport == "sendgrid") {
			let sgTransport = require("nodemailer-sendgrid-transport");
			transporter = nodemailer.createTransport(sgTransport({
				auth: {
					api_key: config.mailer.sendgrid.apiKey
				}
			}));
		}

		if (transporter) {
			transporter.use("compile", htmlToText());
			transporter.sendMail(mailOptions, (err, info) => {
				if (err)
					logger.warn("Unable to send email: ", err);
				else
					logger.info("Email message sent.", info.response);
				
				if (cb)
					cb(err, info);
			});
		}
		else 
			logger.warn("Unable to send email! Invalid mailer transport: " + config.mailer.transport);
	}
Beispiel #30
0
const express = require('express');
const router = express.Router();
const nodemailer = require('nodemailer');
const sgTransport = require('nodemailer-sendgrid-transport');
const config = require('../config/config');

// send grid options
const sendGridOptions = {
  auth: {
    api_user: config.API_USERNAME,
    api_key: config.API_KEY
  }
};

// configure nodemailer client
var client = nodemailer.createTransport(sgTransport(sendGridOptions));

// routes
// Home route
router.get('/', (req, res) => {
  res.render('index');
})

router.get('/contact', (req, res) => {
  res.send('reply');
})

// Subscribe to blog
router.post('/contact', (req, res) => {
  // Email object
  let email = {