I created an email.js module instantiating nodemailer. I was able to send/receive email with gmail normally by running node email.js (with to, for, subject, text already filled in in the code).
At the moment I'm trying to use the submit input from my form to trigger nodemailer (which now needs to access the values of the inputs filled in on the site and send it by email). I can't do this by assigning onclick="Send()" to the form's submit input.

HTML:

```
<section class="sec-form">
            <form name="form_contato" method="post" id="form-block">
                <h1 id="contato">Contato</h1>
                <input type="text" id="nomeid" placeholder="Seu nome" name="nome" required/>
                <input type="email" id="emailid" placeholder="E-mail" name="email" required/>
                <input type="text" id="assuntoid" placeholder="Assunto"/>
                <textarea id="mensagemid" placeholder="Deixe sua mensagem..." rows="6" maxlength="1300" required></textarea>
                <input type="submit" id="enviar" value="Enviar" onclick="Enviar()"/>
            </form>
        </section>

```

JS:

```js
const dotenv = require('dotenv').config();
const nodemailer = require("nodemailer");

const express = require('express');
const app = express();
const port = 5500;

app.listen(port, () => {
    console.log(`Listening at http://localhost:${port}`)
});

//Input submit onclick
function Enviar() {
    let nome = document.getElementById('nomeid');
    let email = document.getElementById('emailid');
    let assunto = document.getElementById('assuntoid');
    let mensagem = document.getElementById('mensagemid');
    let transporter = nodemailer.createTransport({
        service: 'gmail',
        auth: {
            type: "login",
            user: process.env.EMAIL_USER,
            pass: process.env.EMAIL_PASS,
        },
    });

    let mailOptions = {
        from: 'services.mail.sender@gmail.com',
        to: 'luciano.rocha.dev@gmail.com',
        subject: 'Static Resp Web - Nodemailer',
        text:
        `Nome: ${nome.value},
        E-mail: ${email.value},
        Assunto: ${assunto.value},
        Mensagem: ${mensagem.value}`
        //attachments: [ { filename: , path: , contentType: , } ]
    };

    transporter.sendMail(mailOptions, function (err, data) {
        if (err) {
            console.log("Error " + err);
        } else {
            alert(`Obrigado ${nome.value}, sua mensagem foi enviada com sucesso!`)
            console.log("E-mail enviado com sucesso.");
        }
    });
}
```

I'm using live-server on VS Code. I didn't find a state other than onclick for when the submit works after all the form is filled out correctly (html5 validation). My idea was to use this state to trigger the nodemailer function. Is there a better way to implement this? Thanks!