Problems with nodemailer

Hi there!
A few days ago I was able to learn to use nodemailer and confirm to send me an email with data from the body of an html. Now I want to integrate this into a project that I am starting and for some reason it does not take the POST route that I have created for said event. Any help is welcome.

Here is the repository with the code:

Thank you

Hey welcome! You should put it up on Glitch so it’s easier for someone to remix it. Also…it’s Glitch’s forum :slight_smile:

Here is the app

const express = require ('express');
const path = require('path');
const swig = require('swig');

const contactoRouters = require('./routes/contacto');

//Setup
const app = express();

app.use(express.urlencoded({extended: false}));
app.use(express.json());

app.use(express.static(path.join(__dirname, "public")));
//app.set('view engine', 'ejs'); ACA ESTÁN LOS DOS ENGINES, EJS Y PARA HTML.
app.engine('html', swig.renderFile);
app.set('view engine', 'html');
app.set('views', path.join(__dirname, 'views'))



//Routes

app.get('/', (req,res) => {
    res.render("home")
});

app.use('/contacto', contactoRouters);




app.get('*', function(request, response){
    response.render('404',{
      code: '404',
      error: 'Página no encontrada'
    })
  });

  app.listen(3000, () => {
    console.log('El server trabaja en el puerto 3000')
});

the contacto route

const express = require('express');
const router = express.Router();


router.get('/', (request, response) => {
  response.render('contacto');
})

router.post('/send-email', async (req, res) => {
  const { name, email, phone, message } = req.body;
  
  contentHTML = `
      <h1>User Information</h1>
      <ul>
          <li>Username: ${name}</li>
          <li>User Email: ${email}</li>
          <li>User Phone: ${phone}</li>
      </ul>
      <p>${message}</p>
  `;

  console.log(contentHTML);

const transporter = nodemailer.createTransport({
      host: 'smtp.gmail.com',
      port: 465,
      secure: true,
      auth: {
          user: `gervasioriveiro@gmail.com`,
          pass: `****************`
      },
      tls:{
          rejectUnauthorized: false
      }
  });


const info = await transporter.sendMail({
      from: '"Server Gmail" <gervasioriveiro@gmail.com>',
      to: 'gervasioriveiro@gmail.com',
      subject: 'Mail de prueba',
      html: contentHTML
  })


console.log('Message sent', info.messageId);


});

/*transporter.verify().then(() =>{
  console.log('Ready for send emails');
})

module.exports = router;*/


//app.use(require('./middlewares/nodemailer'));

module.exports = router;

Ande the view contacto

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" href="main.css">
    <script src="https://kit.fontawesome.com/62ddc7885f.js" crossorigin="anonymous"></script>
    <title>La Peligrosa-Contacto</title>
</head>
<body>

    <div class= "containercontacto">
        <nav class="nav">
            <button class="botonhome">
                <a href="/">
                    <i class="fas fa-home fa-2x"></i>
                </a>
            </button>
            <img class="logo" src="/assets/5296e1c98737878b714cf027c02cdefb.jpg">
            <ul class="lista">
                <li>Próximos Remates</li>
                <li>
                    <a href="productos.html">Nuestros Productos</a>
                </li>
                <li>Cabalgatas Turísticas</li>
                <li>Contacto</li>
                <li>Ubicación</li>
            </ul>
        </nav>
        
        <div class="maincontacto">
            <ul class="listacontacto">
                <li>
                    <div class="whasap">
                        <i class="fab fa-whatsapp-square fa-2x"></i>
                        <p>Whatsapp - 093 967 602</p>
                    </div>
                </li>
                <li>
                    <div class="facebook">    
                        <button>
                            <a href="https://www.facebook.com/Chacra-la-peligrosa-116789810177665/">
                                <i class="fab fa-facebook-square fa-2x"></i>
                            </a>
                        </button>
                            <p>facebook</p>
                            </i>
                    </div>
                </li>    
            </ul>
            <div class="menssage">
                <form action="send-mail" method="POST">
                    <input type="text" name="name" placeholder="NOMBRE">
                    <input type="text" name="mail" placeholder="CORREO">
                    <input type="text" name="phone" placeholder="TELÉFONO">
                    <textarea name="message" class="message" placeholder="DEJA TU MENSAJE AQUÍ... " id="message"></textarea>
                    <button class="botonenviar">ENVIAR </button>
                </form>   
            </div>   
        </div>
        <div class="footer">@2021</div>
    </div>
</body>
</html>

Ty Christina :slight_smile: