title: Nodemailer script does not execute when called from the website
body: <p>I'm trying to use Nodemailer to send emails by clicking submit on a web form. The test strings of the embedded script are being printed, but after that the script fails with this message in the console: </p>
  
  <p>ReferenceError: require is not defined</p>
  
  <p>What's interesting is that I receive emails from this script when I run it directly from the terminal, but when I try to trigger it from my web form, I get this error.</p>
  
  <p>Almost everywhere I've looked people present a script such as the one directly below as being the only thing needed to send emails using Nodemailer. Neither the Nodemailer website nor W3Schools make reference to anything else. What am I missing? </p>
  
  <p>Thank you for your time,</p>
  
  <p>-Joel</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;script&gt;
    const myForm = document.getElementById('myForm');
    console.log("Testing!");
    myForm.addEventListener("click", () =&gt; {
      var nodemailer = require('nodemailer');
  
      var transporter = nodemailer.createTransport({
  
    service: 'gmail',
    auth: {
           user: 'angleritemailer@gmail.com',
           pass: 'hammertime80'
       }
   });
  
  
   const mailOptions = {
    from: 'angleritemailer@gmail.com',
    to: 'joelnashjobs@yahoo.com',
    subject: 'hey',
    text : 'text',
    html: '&lt;p&gt;Your html here&lt;/p&gt;'
   }
  
      transporter.sendMail(mailOptions, function(err, info) {
        if (err)
          console.log(err)
        else
          console.log(info);
      });
    });
  &lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form" class = "col-sm-6" action = "/" method = "POST" id = "myForm"&gt; 
                          &lt;div class = "row form-row form-group"&gt;
  
                              &lt;div class = "col-sm-5"&gt;
                                  &lt;input type = "text" class = "form-control-plaintext full-width" id = "name" placeholder = "Your name here"&gt;
                              &lt;/div&gt;
  
                              &lt;div class = "col-sm-2"&gt;
                              &lt;/div&gt;
  
                              &lt;div class = "col-sm-5 widen-slightly"&gt;
                                  &lt;input type = "text" class = "form-control-plaintext full-width" id = "staticEmail" placeholder = "email@example.com"&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
  
                          &lt;div class = "row form-row form-group"&gt;
  
                              &lt;div class = "col-sm-12 widen-slightly"&gt;
                                  &lt;input type = "text" class = "form-control-plaintext full-width" id = "phone" placeholder = "Phone number with area code"&gt;
                              &lt;/div&gt;
  
                          &lt;/div&gt;
  
                          &lt;div class = "row form-row form-group"&gt;
  
                                  &lt;div class = "col-sm-12 widen-slightly"&gt;
                                      &lt;input type = "text" class = "form-control-plaintext full-width" id = "subject" placeholder = "Subject"&gt;
                                  &lt;/div&gt;
                          &lt;/div&gt;
  
                          &lt;div class = "row form-row form-group"&gt;
  
                                  &lt;div class = "col-sm-12 widen-slightly"&gt;
                                      &lt;textarea rows = "6" class = "form-control-plaintext full-width" id = "Description" placeholder = "Description"&gt;&lt;/textarea&gt;
                                  &lt;/div&gt;
                          &lt;/div&gt;
  
                          &lt;div class = "row form-row form-group"&gt;
                              &lt;label  class = "col-sm-3 col-form-label" &gt;Any Photos&lt;/label&gt;
  
  
  
                              &lt;div class = "col-sm-7"&gt;
                                  &lt;input type = "file" class = "form-control-file full-width" id = ""&gt;
                              &lt;/div&gt;
  
                              &lt;div class = "cl-sm-2"&gt; 
                                  &lt;button type="submit" class="btn btn-default" id = "submit"&gt;Submit&lt;/button&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
  
  
  
  
                      &lt;/form&gt;
  </code></pre>