title: How to send encrypted/TLS emails with NodeJS from localhost using send mail
body: <p>I want to be able to send emails from my local domain without using gmail or other SMTP servers. </p>
  
  <p>I'm currently using <a href="https://github.com/guileen/node-sendmail" rel="nofollow noreferrer">SendMail</a>: </p>
  
  <pre><code>const sendmail = require('sendmail') ({
      logger: {
          debug: console.log,
          info: console.info,
          warn: console.warn,
          error: console.error
      },
      dkim: {
          privateKey: dkimPrivateKey,
          keySelector: 'default'
      },
  });
  
  
  sendmail({
          from: 'foo@mydomain.com',
          to: 'mygmail@gmail.com',
          subject: 'test sendmail',
          html: 'Mail of test sendmail ',
      }, function(err, reply) {
          console.log(err &amp;&amp; err.stack);
          console.dir(reply);
  });
  </code></pre>
  
  <p>and this DOES work, BUT when I receive the email in my Gmail account, and I view the message information, <strong>Google is marking this as 'security:     No encryption'</strong> </p>
  
  <p>From what I understand I need to use TLS to create a 'secure' connection. I already have a certificate and keys from LetsEncrypt and my domain is already using HTTPS. How do I encrypt/use TLS my outgoing emails?</p>
  
  <p>Or is there a better package for this? I've tried using <a href="https://nodemailer.com/extras/smtp-connection/" rel="nofollow noreferrer">NodeMailer</a> and my emails only get added to a 'queue' and never sent. What is the problem? </p>