title: Nodejs and Nodemailer to receive user ip address?
body: <p>Hello i  want  to  to echo this command <code>request.connection.remoteAddress</code>
  In node.js |  to echo the  user ip  address can someone help</p>
  
  <p>i am trying to receive contact emails through nodemailer with this code </p>
  
  <pre><code>const bodyParses = require('body-parser');
  const exphbs = require('express-handlebars');
  const path = require('path');
  const nodemailer = require('nodemailer');
  
  const app = express();
  
  
  
  // View engine setup
  app.engine('handlebars', exphbs());
  app.set('view engine', 'handlebars');
  
  // Main Folder
  app.use('/public', express.static(path.join(__dirname, 'public')));
  //Body Parses Middleware
  app.use(bodyParses.urlencoded({ extended: false}));
  app.use(bodyParses.json());
  
  
  app.get('/', (req, res) =&gt; {
    res.render('contact', {layout: false});
  });
  
  app.post("/send", async (req,res,next) =&gt; {
    const output = `
    &lt;p&gt;You have a new contact requiest&lt;/p&gt;
    &lt;h3&gt;Detajet&lt;/h3&gt;
    &lt;ul&gt;
    &lt;li&gt;Name: ${req.body.name}&lt;/li&gt;
    &lt;li&gt;Comapny: ${req.body.company}&lt;/li&gt;
    &lt;li&gt;Email: ${req.body.email}&lt;/li&gt;
    &lt;li&gt;Phone: ${req.body.phone}&lt;/li&gt;
    &lt;li&gt;${res.send(ip+"\n")}&lt;/li&gt;
    &lt;/ul&gt;
    &lt;h3&gt;Message&lt;/h3&gt;
    &lt;p&gt;${req.body.message}&lt;/p&gt;
    `;
    let transporter = nodemailer.createTransport({
      host: "smtp.gmail.com",
      port: 465,
      secure: true, // true for 465, false for other ports
      auth: {
        user: 'user@gmail.com', // generated ethereal user
        pass: 'password' // generated ethereal password
      },
      tls:{
        rejectUnauthorized:false
      }
    });
  
    // send mail with defined transport object
    let info = await transporter.sendMail({
      from: '"Tipi" &lt;aj.production15@gmail.com&gt;', // sender address
      to: "test@gmail.com", // list of receivers
      subject: "test", // Subject line
      text: "Hello world?", // plain text body
      html: output // html body
    });
  
    console.log("Message sent: %s", info.messageId);
    console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
  
    res.render('tjetra', {layout: false});
  
  main().catch(console.error);
  });
  
  app.listen(3000, () =&gt; console.log('Server started...'));
  </code></pre>
  
  <p>So i am trying when i receive the email to get and the user ip too.
  I think i should use the code : request.connection.remoteAddress but i do not know how to connect when the user submit the form to send me and the user ip address.</p>