Nodemailer contact form is being hit by spambots submitting bogus data

58
May 16, 2019, at 02:40 AM

Having issues with Spambots submitting bogus data to my nodemailer contact form from my express app which is live on a digital ocean droplet.

I tried setting up a hidden form field that redirects and prevents form submission but that does not seem to be working.

app.post("/products/contactCorporate", function (req, res) {
  let { name, email, message, businessAddress } = req.body;
  //businessAddress is a hidden field on my form
  if (businessAddress.length !== 0) {
    req.flash('success', 'Sorry Bot!');
    res.redirect("/products/contactCorporate");
  } else {
    submitForm();
  }
});

I would like to find an NPM package or solution to verify the email on the backend before form submission or trick the bot in some way. I would rather not use a captcha.

Any help is greatly appreciated.

Answer 1

I was able to get it done with the NPM package a email-existence

Existence is determined by telnetting to the MX server of the email domain and attempting to send an email to the supplied address. MX servers return 250 if the email address exists and 550 if it does not.

app.post("/products/contactCorporate", function (req, res) {
  let { name, email, message, businessAddress } = req.body;
  emailExistence.check(email, function (error, response) {
    if (response === false) {
      req.flash('success', 'Sorry, the email seems to be spam!');
      res.redirect("/products/contactCorporate");
    } else {
      submitForm();
    }
  });
});
READ ALSO
How to show progress on a progress bar (Retrofit Download)

How to show progress on a progress bar (Retrofit Download)

I'm using Retrofit to download a file from the internet, and I want to do a progress bar that show the progress of the download, but I'm having problems doing that, I was able to do a notification (is not perfect) but is working at some point

10
How can I make a posts category filter with checkboxes?

How can I make a posts category filter with checkboxes?

On my blog archive page, I'm trying to make a category filter with checkboxes so visitors can filter posts by categories without reloading the pageBut I get stuck how to hide items with categories that are not checked

14
How to Sort a select box of strings with numbers using JavaScript

How to Sort a select box of strings with numbers using JavaScript

I'm trying to sort an array of Select options, but the options contain a number at the end of the stringSo how can I sort not only by the beginning letter, but also by the number?

23
i am do a blog, the user lays out the post and I want that he could not post more than 1 post [on hold]

i am do a blog, the user lays out the post and I want that he could not post more than 1 post [on hold]

Iam do a blog, the user lays out the post and I want that he could not post more than 1 postI have a blog base, a user logs in with their data and clicks to create a post, now you need to do so that when you log in, if the user already has a post, there was no button...

47