title: How to upload multiple images to nodemailer as an attachment?
body: <p>how to add image name and url of the multiple images to the attachments field once the post method is triggerd?</p>
  <p>this is my app.js file.</p>
  <pre><code>const express = require(&quot;express&quot;);
  const bodyParser = require(&quot;body-parser&quot;);
  const ejs = require(&quot;ejs&quot;);
  const nodemailer = require('nodemailer');
  const app = express();
  app.set('view engine', 'ejs');
  app.use(bodyParser.urlencoded({extended: true}));
  
  const transporter = nodemailer.createTransport({
      service: &quot;hotmail&quot;,
      auth: {
          user: &quot;user-mail&quot;,
          pass: &quot;user-password&quot;
      }
  });
  
  app.get('/',(req,res) =&gt; {
      res.render('index')
  });
  
  app.post('/',(req,res)=&gt;{
  
      const options = {
        from: &quot;sender email&quot;, // sender address
        to: &quot;receiver email&quot;, // list of receivers
        subject: &quot;New Article&quot;, // Subject line
        text: `from: ${req.body.fname} ${req.body.lname}`, // plain text body
        html: &quot;&lt;p&gt;text&lt;/p&gt;&quot;,
        attachments: []
      }
  
      transporter.sendMail(options, function (err, info) {
                   if (err) {
                       console.log(err);
                   }else{
                      console.log(&quot;Sent:  &quot;, info.response);
                      res.Send(&quot;You have successfully sent me mail&quot;);
                   }    
      });
  
  });
  
  app.listen(4000,()=&gt;console.log(&quot;Server started on port 4000&quot;))
  </code></pre>
  <p>my index file snippet for img upload element.
  User can add multiple images to the form</p>
  <pre><code> &lt;label class=&quot;upload__btn&quot;&gt;
         &lt;p&gt;Upload images&lt;/p&gt;
         &lt;input
                type=&quot;file&quot;
                multiple=&quot;&quot;
                name=&quot;upload&quot;
                data-max_length=&quot;20&quot;
                class=&quot;upload-img&quot;
              /&gt;
  &lt;/label&gt;
  </code></pre>