title: Nodemailer keeps giving me an error: "TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or..."
body: <p>The full error is EXTREMELY long, but here is a snippet:</p>
  
  <pre><code>    TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of Object
      at PassThrough.Writable.write (_stream_writable.js:289:13)
      at PassThrough.Writable.end (_stream_writable.js:583:10)
      at Immediate._onImmediate (C:\Users\small\desktop\career-change\coding-round-2\portfolio-round1\recipe-app\projectv2\node_modules\nodemailer\lib
  \mime-node\index.js:969:46)
      at processImmediate (internal/timers.js:456:21) {
    code: 'ERR_INVALID_ARG_TYPE'
  }
  </code></pre>
  
  <p>This is my first time using nodemailer, or any emailing service for that matter. I originally started using it with my personal gmail account, then was getting the issue where gmail was blocking it because it was considered a less secure app. So I changed my email settings to allow access from less secure apps. And then I began getting this error.</p>
  
  <p>I also tried using <a href="https://ethereal.email/" rel="nofollow noreferrer">https://ethereal.email/</a> to autogenerate an email test account so that I could avoid using gmail, just in case that was the issue.</p>
  
  <p>Here is my nodemailer code:</p>
  
  <pre><code>const express = require("express");
  const router = express.Router();
  const bodyParser = require("body-parser");
  const nodemailer = require("nodemailer");
  
  router.post("/contact", (req, res) =&gt; {
    const output = {
      msg: `You have a new contact request from ${req.body.name}`,
      userEmail: req.body.userEmail,
      subject: req.body.subject,
      message: req.body.message,
    };
    console.log(res);
  
    // create reusable transporter object using the default SMTP transport
    let transporter = nodemailer.createTransport({
      host: "smtp.ethereal.email",
      port: 587,
      auth: {
        user: "ida.pollich73@ethereal.email",
        pass: "JPtPvputy6n8JBzYe2",
      },
    });
  
    let mailOptions = {
      from: '"Nodemailer Contact" &lt;mypersonalaccount@gmail.com&gt;', // sender address
      to: "differentpersonalaccount@gmail.com", // list of receivers
      subject: "Node Contact Request", // Subject line
      text: output, // plain text body
      html: output, // html body
    };
  
    // send mail with defined transport object
    transporter.sendMail(mailOptions, (error, info) =&gt; {
      if (error) {
        return console.log(error);
      } else {
        console.log(info);
      }
      res.send("email sent");
      console.log("Message sent: %s", info.messageId);
      // Message sent: &lt;b658f8ca-6296-ccf4-8306-87d57a0b4321@example.com&gt;
  
      // Preview only available when sending through an Ethereal account
      console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
      // Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
    });
  });
  
  module.exports = router;
  </code></pre>
  
  <p>Does anybody have any idea what the error means? Let me know if you need any more info.</p>