title: How to send mail through nodemailer
body: <p>I am trying to send a simple mail through my website to my own other account. But it does not work. I am using node mailer and have followed the documentation precisely.</p>
  
  <p>I have tried checking for any kind of syntax error or external factors. </p>
  
  <pre><code>//Send Mail
  router.post('/volunteer', ensureAuthenticated, async(req, res) =&gt; {
  
      // const { name, email, city } = req.body;
      //Create the transporter
      require('dotenv').config();
      const nodemailer = require('nodemailer');
  
      let transporter = nodemailer.createTransport({
          service: 'gmail',
          auth: {
              user: process.env.EMAIL,
              pass: process.env.PASSWORD
          }
      });
  
      //set up mailOptions
      let mailOptions = {
          from: 'readsocially001@gmail.com',
          to: 'vaibhav.ag.001@gmail.com',
          subject: 'Volunteer',
          text: 'HEY'
      };
  
      transporter.sendMail(mailOptions, function (err, data) {
          if (err) {
              console.log("some error");
          } else {
              console.log("SENT");
          }
  
      });
      res.redirect('/volunteer');
  });
  </code></pre>
  
  <p>It just goes into the <code>if(err)</code> statement and prints some error. The actual error is:</p>
  
  <pre><code>Error: Missing credentials for "PLAIN"
      at SMTPConnection._formatError (/Users/vaibhav2001/Documents/test/ReadSocially/node_modules/nodemailer/lib/smtp-connection/index.js:781:19)
      at SMTPConnection.login (/Users/vaibhav2001/Documents/test/ReadSocially/node_modules/nodemailer/lib/smtp-connection/index.js:452:38)
      at connection.connect (/Users/vaibhav2001/Documents/test/ReadSocially/node_modules/nodemailer/lib/smtp-transport/index.js:271:32)
      at SMTPConnection.once (/Users/vaibhav2001/Documents/test/ReadSocially/node_modules/nodemailer/lib/smtp-connection/index.js:209:17)
      at Object.onceWrapper (events.js:286:20)
      at SMTPConnection.emit (events.js:198:13)
      at SMTPConnection._actionEHLO (/Users/vaibhav2001/Documents/test/ReadSocially/node_modules/nodemailer/lib/smtp-connection/index.js:1309:14)
      at SMTPConnection._processResponse (/Users/vaibhav2001/Documents/test/ReadSocially/node_modules/nodemailer/lib/smtp-connection/index.js:940:20)
      at SMTPConnection._onData (/Users/vaibhav2001/Documents/test/ReadSocially/node_modules/nodemailer/lib/smtp-connection/index.js:746:14)
      at TLSSocket.SMTPConnection._onSocketData (/Users/vaibhav2001/Documents/test/ReadSocially/node_modules/nodemailer/lib/smtp-connection/index.js:189:46)
      at TLSSocket.emit (events.js:198:13)
      at addChunk (_stream_readable.js:288:12)
      at readableAddChunk (_stream_readable.js:269:11)
      at TLSSocket.Readable.push (_stream_readable.js:224:10)
      at TLSWrap.onStreamRead [as onread] (internal/stream_base_commons.js:94:17) code: 'EAUTH', command: 'API' }
  </code></pre>