title: Nodemailer stops sending mails after a while
body: <p>I'm using Nodemailer to send mails if &quot;/send&quot; is called with an email (receiver) and token variable. It works perfectly however it stops responding after a few hours... It has worked for days before without problems but recently it can't even last a few hours.</p>
  <p>No error codes are displayed, cmd only shows the output of the last sent email. It still runs, but doesn't respond to &quot;/send&quot; calls anymore. Is this a known issue? What can I do to figure out what's wrong?</p>
  <p>Below is my app.js. It's nothing special, mostly standard nodemailer code.</p>
  <pre><code>const express = require(&quot;express&quot;);
  const bodyParser = require(&quot;body-parser&quot;);
  const exphbs = require(&quot;express-handlebars&quot;);
  const path = require(&quot;path&quot;);
  const nodemailer = require(&quot;nodemailer&quot;);
  const cors = require(&quot;cors&quot;);
  const app = express();
  const smtpTransport = require('nodemailer-smtp-transport');
  
  const https = require('https') // to run https
  var fs = require('fs') // to run https
  
  // View engine setup
  app.engine(&quot;handlebars&quot;, exphbs({ defaultLayout: false }));
  app.set(&quot;view engine&quot;, &quot;handlebars&quot;);
  
  // Static folder
  app.use(&quot;/public&quot;, express.static(path.join(__dirname, &quot;public&quot;)));
  app.use(cors());
  
  // Body Parser Middleware
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(bodyParser.json());
  
  app.get(&quot;/&quot;, (req, res) =&gt; {
    res.render(&quot;contact&quot;);
  });
  
  app.post(&quot;/send&quot;, (req, res) =&gt; {
      const email = req.body.data.email;
      const token = req.body.data.token;
      const output = fs.readFileSync('employee.html').toString().replace(&quot;${token}&quot;, token);
  
    // create reusable transporter object using the default SMTP transport
    let transporter = nodemailer.createTransport(smtpTransport({
      name: &quot;myname&quot;,
      host: &quot;myhost&quot;,
      port: 465,
      secure: true, // true for 465, false for other ports
      auth: {
        user: &quot;info@myhost.nl&quot;,
        pass: &quot;123456&quot;,
      },
      tls: {
        rejectUnauthorized: false,
      },
      logger: true, // If set to true then logs to console.
      debug: true, // if set to true, then logs SMTP traffic, otherwise logs only transaction events.
    }));
  
    // setup email data with unicode symbols
    let mailOptions = {
      from: '&quot;MyName&quot; &lt;info@myhost.nl&gt;', 
      to: email,
      subject: &quot;account&quot;, 
      html: output, 
    };
  
    // send mail with defined transport object to employee
    transporter.sendMail(mailOptions, (error, info) =&gt; {
      if (error) {
        return console.log(error);
      }
      res.render(&quot;contact&quot;, { msg: &quot;Email has been sent&quot; });
      console.log(&quot;Email has been sent&quot;);
    });
  });
  
  https.createServer({
    key: fs.readFileSync('../cert/private.key'),
    cert: fs.readFileSync('../cert/certificate.crt')
  }, app)
  .listen(3001, function () {
    console.log('Example app listening on port 3001! Go to https://localhost:3001/')
  })
  </code></pre>