title: How do I get nodemailer to work?
body: <p>I cannot figure out how to get nodemailer to work, I have inserted my credentials for gmail too and tried sending an email to myself but it did not send me anything and it did not err, so I am confused. It is possible that I am missing stuff from my code... </p>
  
  <p>here is the email file:</p>
  
  <pre><code>var nodemailer = require('nodemailer');
  var config = require('./config/config');
  
  var smtpTransport = nodemailer.createTransport("SMTP",{
      service: "Gmail",
      auth: {
          user: config.mailer.auth.user,
          pass: config.mailer.auth.pass
      }
  });
  
  var EmailAddressRequiredError = new Error('email address required');
  
  
  exports.sendOne = function(templateName, locals, fn) {
      if(!locals.email) {
          return fn(EmailAddressRequiredError);
      }
  
      if(!locals.subject) {
          return fn(EmailAddressRequiredError);
      }
  
      // template
      var transport = smtpTransport;
      transport.sendMail({
          from: config.mailer.defaultFromAddress,
          to: locals.email,
          subject: locals.subject,
          html: html,
          text: text
      }, function (err, responseStatus) {
          if(err) {
              return fn(err);
          } 
          return fn(null, responseStatus.message, html, text);
      });
  
  };
  </code></pre>
  
  <p>Here is the route file sending the email:</p>
  
  <pre><code>exports.forgotPasswordPost = function(req, res, next) {
      console.log("Forgot Password Post");
      if(req.body.email === '') {
          console.log('err');
      } else {
      crypto.randomBytes(48, function(ex, buf) {
          var userToken = buf.toString('hex');
          console.log(userToken);
          User.findOne({email: (req.body.email)}, function(err, usr) {
              if(err || !usr) {
                  res.send('That email does not exist.');             
              } else {
                  console.log(usr);
                  //just call the usr found and set one of the fields to what you want it to be then save it and it will update accordingly
                  usr.token = userToken;
                  usr.tokenCreated = new Date ();
                  usr.save(function(err, usr){
                  //  res.redirect('login', {title: 'Weblio', message: 'Your token was sent by email. Please enter it on the form below.'});
                      console.log(usr);
                  });
  
                  console.log(usr);
                  var resetUrl = req.protocol + '://' + req.host + '/password_reset/' + usr.token;
                  console.log(resetUrl);
                  var locals = {
                  resetUrl: resetUrl,
                  };
                  console.log(locals);
                  mailer.sendOne('password_reset', locals, function(err, email) {
                      console.log('email sent');
                      res.redirect('successPost');
                  });
              }
  
  
  
  
          });
      });
      }
  };
  </code></pre>
  
  <p>Do I need anything else beside what I have here? </p>