垃圾邮件提交者伪造了Nodemailer联系表格

时间:2019-05-15 14:29:31

标签: node.js express nodemailer

Spambots在我的Express应用程序中将虚假数据提交到我的nodemailer联系人表单时遇到问题,该应用程序位于数字海洋小滴上。

我尝试设置一个隐藏的表单域,该域重定向并阻止表单提交,但似乎不起作用。

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();
  }
});

我想找到一个NPM软件包或解决方案,以便在提交表单之前以某种方式验证后端的电子邮件,或以某种方式欺骗该机器人。我宁愿不使用验证码。

非常感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

我能够使用NPM软件包email-existence

完成它

存在是通过远程登录到电子邮件域的MX服务器并尝试将电子邮件发送到提供的地址来确定的。如果电子邮件地址存在,则MX服务器返回250,如果电子邮件地址不存在,则返回550。

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();
    }
  });
});