title: Send route not being found,
body: <p>I am trying to use nodemailer to send an email from the contact page. I have built the site with a MERN stack. All the other routes work perfectly fine. I can setup a new user, write a post and login an existing user. The only part where the routes break is when the mail is sent on the contact page.</p>
  <p>Below is the middleware:</p>
  <pre><code>const app = express();
  
  // Connect Database
  connectDB();
  
  // Init Middleware
  app.use(express.json());
  
  // Define Routes
  app.use('/api/users', require('./routes/api/users'));
  app.use('/api/auth', require('./routes/api/auth'));
  app.use('/api/profile', require('./routes/api/profile'));
  app.use('/api/posts', require('./routes/api/posts'));
  app.use('/api/send', require('./routes/api/send'));
  </code></pre>
  <p>Below is the send route:</p>
  <pre><code>var express = require('express');
  var config = require('config');
  var router = express.Router();
  var nodemailer = require('nodemailer');
  var cors = require('cors');
  
  // @route   POST api/send
  // @desc    Send email on contact page
  // @access  Public
  
  router.post('/send',(req, res ) =&gt; {
      var name = req.body.name
      var email = req.body.email
      var subject = req.body.subject
      var message = req.body.message
      var content = `
      name: ${name} \n 
      email: ${email} \n 
      subject: ${subject} \n 
      message: ${message} `
  
      var mail = {
        from: name,
        to: receiver, // receiver email,
        subject: subject,
        text: content
      }
      transporter.sendMail(mail, (err, data) =&gt; {
        if (err) {
          res.json({
            status: 'fail'
          })
  
        } else {
          res.json({
           status: 'success'
          })
        }
      })
    });
  
    module.exports = router;
  </code></pre>
  <p>I get a 404 error when I submit the form on contact page. Below is the contact page:</p>
  <pre><code>const ContactForm = () =&gt; {
    const [state, setState] = useState({
      name: '',
      email: '',
      subject: '',
      message: ''
    });
  
    const [result, setResult] = useState(null);
  
    const sendEmail = event =&gt; {
      event.preventDefault();
      axios
        .post('/send', { ...state })
        .then(response =&gt; {
          setResult(response.data);
          setState({
            name: '',
            email: '',
            subject: '',
            message: ''
          });
        })
        .catch(() =&gt; {
          setResult({
            success: false,
            message: 'Something went wrong. Try again later'
          });
        });
    };
  
    const onInputChange = event =&gt; {
      const { name, value } = event.target;
  
      setState({
        ...state,
        [name]: value
      });
    };
  </code></pre>
  <p>This is my handler:</p>
  <pre><code>const nodemailer = require ('nodemailer');
  
  nodemailer.createTransport({
      host: &quot;smtp.gmail.com&quot;, //replace with your email provider
      port: 587,
      auth: {
          user: process.env.email,
          pass: process.env.password
      }
  }); 
  
  // verify connection configuration
  transporter.verify(function(error, success) {
      if (error) {
        console.log(&quot;error at mail send&quot;);
      } else {
        console.log(&quot;Server is ready to take the messages&quot;);
      }
    });
  
  module.exports = transporter
  </code></pre>
  <p>To debug I have tried to change the POST route to
  <code>(req, res, next)</code>
  <code>(req, res, send)</code></p>