title: What is correct way of using Nodemailer in expressjs?
body: <p>I am trying to use <a href="https://github.com/andris9/Nodemailer" rel="noreferrer">nodemailer</a> in expressjs app. Should I keep creating of transport object out of route handler or creating transport object inside route handler is just fine?</p>
  
  <pre><code>var express = require('express')
    , app = express()
    , nodemailer = require('nodemailer');
  
    smtpTrans = nodemailer.createTransport('SMTP', {
        service: 'Gmail',
        auth: {
            user: "me@gmail.com",
            pass: "application-specific-password" 
        }
    });
    app.post('/register', function(req, res){
      smtpTrans.sendMail(mailOptions);
    });
  </code></pre>
  
  <p>or </p>
  
  <pre><code>var express = require('express')
    , app = express()
    , nodemailer = require('nodemailer');
  
    app.post('/register', function(req, res){
      smtpTrans = nodemailer.createTransport('SMTP', {
        service: 'Gmail',
        auth: {
            user: "me@gmail.com",
            pass: "application-specific-password" 
        }
      });
      smtpTrans.sendMail(mailOptions);
    });
  </code></pre>