title: NodeJS sending e-mails with a delay
body: <p>I'm using <a href="https://nodemailer.com/" rel="nofollow noreferrer">Nodemailer</a> to send mailings in my NodeJS / Express server. Instead of sending the mail directly I want to wait 20 minutes before sending the mail. I think this feels more personal then sending mail directly. </p>
  
  <p>But I have no idea how to achieve this. I guess I don't need something like a NodeJS cronjob like this <a href="https://www.npmjs.com/package/node-cron" rel="nofollow noreferrer">NodeCron</a> package, or do I?</p>
  
  <pre><code>router.post('/', (req, res) =&gt; {
      const transporter = nodemailer.createTransport(smtpTransport({
        host: 'smtp.gmail.com',
        port: 465,
        auth: {
            user: 'noreply@domain.nl',
            pass: 'pass123'
        }
      }));
  
      const mailOptions = {
        from: `"${req.body.name}" &lt;${req.body.email}&gt;`,
        to: 'info@domain.nl',
        subject: 'Form send',
        html: `Content`
      };
  
      transporter.sendMail(mailOptions, (error, info) =&gt; {
        if (error) res.status(500).json({ responseText: error });
        res.status(200).json({ responseText: 'Message send!' });
      });
    }
  }); 
  </code></pre>
  
  <p>My router looks like as shown above. So if post is called I want this request to wait 20 minutes. Instead of with a cronjob I want to execute the post just once, but with a bit of a delay. Any suggestions on how to do this?</p>