简体   繁体   English

Email 反垃圾邮件 PHP

[英]Email anti spam PHP

I have a contact form with no sort of spam protection on my site and im receiving lots of spam, I'm going to add anti spam protection, I know i can do this with PHP, but if I stopped the form from validation if an anti spam question was wrong using jQuery, would this be sufficient?我的网站上有一个没有垃圾邮件保护的联系表单,我收到了很多垃圾邮件,我将添加反垃圾邮件保护,我知道我可以使用 PHP 来做到这一点,但是如果我停止验证表单,如果反垃圾邮件问题使用 jQuery 是错误的,这就足够了吗? or do spam bots bypass javascript security measures?还是垃圾邮件机器人会绕过 javascript 安全措施?

One real simple trick is to add a input field with css style of display none.一个真正简单的技巧是添加一个 css 样式的输入字段,不显示。 Then check if that field got filled.然后检查该字段是否已填充。 Since it's hidden, only bots would fill it.由于它是隐藏的,因此只有机器人会填充它。 In php you could check if that field got filled, and if so, block it.在 php 中,您可以检查该字段是否已填充,如果已填充,则阻止它。

I would use a reCAPTCHA .我会使用reCAPTCHA Its pretty simple to integrate it and its well documented.集成它非常简单并且有据可查。

Give it a try.试试看。 It'll totally do its job on preventing against spam.它将完全做好防止垃圾邮件的工作。

More here https://developers.google.com/recaptcha/docs/php更多信息https://developers.google.com/recaptcha/docs/php

Edit:编辑:

Official reCaptcha Webside官方 reCaptcha Webside

2 things I do a lot that seem to eliminate almost all spam:我经常做的 2 件事似乎可以消除几乎所有垃圾邮件:

  1. Add a text field with a style that is display:none , when the page is submitted, that field should be set, but empty.添加样式为display:none的文本字段,提交页面时,应设置该字段,但为空。 If it is not empty, it is from a bot.如果它不为空,则它来自机器人。
  2. Don't set the form's action correctly, then use JavaScript to set it correctly.不要把form的action设置正确,然后用JavaScript设置正确。 (Example below) (下面的例子)

Also, a good captcha will generally do the trick, as previously mentioned.此外,如前所述,良好的验证码通常可以解决问题。

<form style="display:none;" id="myform" action="http://www.google.com">
    ...
</form>
<script>
var obj=document.getElementById('myform');
obj.action='realaction.php';
obj.style.display='block';
</script>
<noscript>You must have JavaScript enabled to contact us</noscript>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM