title: nodemailer occasional ETIMEDOUT while alternate method is successful
body: <h2>Context</h2>
  
  <ul>
  <li>Windows Server 2012 R2 Standard, not behind a network proxy</li>
  <li>NodeJS 6.11.3</li>
  <li>Nodemailer 4.1.0</li>
  <li><p>This snippet tries to send email to an in-house SMTP server on the same network that does not require authentication:</p>
  
  <pre><code>var transporter = nodemailer.createTransport({
      host: "smtp.example.com",
      port: 25,
      secure: false
  });
  
  var mailOptions = {
      'from': 'noreply@example.com',
      'to': 'someone@example.com',
      'subject': 'test email',
      'text': 'some text for a body',
  };
  
  transporter.sendMail(mailOptions, (error, info) =&gt; {
      if (error) {
          // do something
      } else {
          // do something else
      }
  });
  </code></pre></li>
  <li><p>The following is an alternate script (VBScript) that we're executing ad hoc just for testing.</p>
  
  <pre><code>Set objMail=CreateObject("CDO.Message")
      objMail.From="noreply@example.com"
      objMail.To="someone@example.com"
      objMail.Subject="Test from new server"
      objMail.TextBody = "This is a message."
      objMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
      objMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.example.com"
      objMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
      objMail.Configuration.Fields.Update
      objMail.Send
  
  Set objMail=nothing
  </code></pre></li>
  </ul>
  
  <h2>Problem</h2>
  
  <ul>
  <li>Set up a <code>setInterval()</code> to try to send email with Nodemailer once per minute.</li>
  <li><p>Sometimes the email is sent but more often we get the following error.</p>
  
  <pre><code>{ Error: connect ETIMEDOUT XXX.XXX.XX.XX:25
          at Object.exports._errnoException (util.js:1020:11)
          at exports._exceptionWithHostPort (util.js:1043:20)
          at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)
      code: 'ECONNECTION',
      errno: 'ETIMEDOUT',
      syscall: 'connect',
      address: 'XXX.XXX.XX.XX',
      port: 25,
      command: 'CONN' }
  </code></pre></li>
  <li>No apparent correlation to restarting the server, frequency of calls to the script, etc.</li>
  <li>What's most strange (to me) is that right in the middle of, say, 40 failed Nodemailer attempts, executing the VBScript sends an email through just fine. It never fails.</li>
  </ul>
  
  <h2>Resolution Attempts</h2>
  
  <ul>
  <li>I've looked at dozens of nodemailer usage examples and read the nodemailer documentation. I can't tell that I'm doing anything wrong; the firewall isn't blocking us, we're not behind a network proxy, the SMTP server doesn't require authentication.</li>
  <li>I don't see any files named <strong>util.js</strong> or <strong>net.js</strong> that I could investigate.</li>
  <li>I've read every Stack Overflow post mentioning the ETIMEDOUT error.</li>
  </ul>
  
  <h2>Questions</h2>
  
  <ul>
  <li>Am I doing anything wrong? If so, what?</li>
  <li>If I'm not, then what could cause this behaviour? What should I ask my system / network admins to investigate?</li>
  </ul>