W
W
wiyod2018-03-02 13:39:59
JavaScript
wiyod, 2018-03-02 13:39:59

Why does nodemailer send mail twice?

For some reason, the email is sent twice.

smtpTransport.sendMail(mailOptions, function(error, response) {
    if(error) {
      res.status(500).json({
        message: 'Message not send. We have issues on our server.'
      })
    }
    else {
      if (response.accepted.length !== 0) {
        res.status(200).json({
          message: 'Your message sent!'
        })
      }
    }
  })

I send from the form on the site. Those. the user fills out a feedback form, sends a POST, and I process it on the server and send a letter to myself. On the Vue.js and Axios front. Maybe because the request is sent twice for some reason? I do not understand.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Skibin, 2018-03-02
@wiyod

1. Check if one POST is actually sent from the user
2. Is your route really connecting in one place? To check, do a console.log('any') before sending, maybe your application logic calls the send code twice

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question