title: Node.js and express: attachment on nodemailer
body: <p>I'd like to attach a file on the email using Nodemailer. I tried several ways following this guide: <a href="https://nodemailer.com/using-attachments/" rel="nofollow noreferrer">https://nodemailer.com/using-attachments/</a>, with .pdf, .txt...but nothing worked.
  Any ideas?
  This is my code with the last try:</p>
  
  <pre><code>router.post('/profilocliente/:id', function(req, res, next) {
    Customer.findById(req.params.id, function(err, customer){
      if(err) throw err;
      var mailOptions={
        to : customer.email,
        subject : req.body.oggetto,
        text : req.body.testo,
        attachments: [{path: 'C:/Users/Angelo/Desktop/test.txt'}]
      }
      console.log(mailOptions);
      smptTransport.sendMail(mailOptions, function(error, response){
        if(error){
          console.log(error);
          res.end("error");
        }else{
          console.log("Message sent: " + response.message);
          res.redirect('/clienti/profilocliente/'+customer._id);
        }
      })
    })
  });
  </code></pre>