使用 PHP 和验证码减少垃圾邮件的最佳实践是什么?
我的网站有以下代码来发送电子邮件。
if($_SESSION["captcha"]==$_POST["captcha"])
{
$msg="Require Services :\t$_POST[service]\n";
$msg="Name :\t$_POST[name]\n";
$msg.="Company Name :\t$_POST[co_name]\n";
$msg.="Address :\t$_POST[address]\n";
$msg.="Mobile :\t$_POST[mobile]\n";
$msg.="Phone :\t$_POST[phone]\n";
$msg.="E-mail :\t$_POST[email]\n";
$msg.="Message :\t$_POST[message]\n";
$subject=$_POST[subject];
$to="[email protected],[email protected]";
$headers="From: $_POST[email] < $_POST[email]> \n";
$headers .= "Reply-To: $_POST[email]\n\n";
mail($to,$subject,$msg,$headers);}
?>
即使使用验证码减少垃圾邮件后,我仍然收到很多垃圾邮件。
My site has the following code to send email.
if($_SESSION["captcha"]==$_POST["captcha"])
{
$msg="Require Services :\t$_POST[service]\n";
$msg="Name :\t$_POST[name]\n";
$msg.="Company Name :\t$_POST[co_name]\n";
$msg.="Address :\t$_POST[address]\n";
$msg.="Mobile :\t$_POST[mobile]\n";
$msg.="Phone :\t$_POST[phone]\n";
$msg.="E-mail :\t$_POST[email]\n";
$msg.="Message :\t$_POST[message]\n";
$subject=$_POST[subject];
$to="[email protected],[email protected]";
$headers="From: $_POST[email] < $_POST[email]> \n";
$headers .= "Reply-To: $_POST[email]\n\n";
mail($to,$subject,$msg,$headers);}
?>
Even after using captcha to reduce junk mail I still get a lot of junk.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
添加一个新的输入字段,将其标记为“请留空”,使用 CSS 隐藏它,如果该字段已填写,则忽略该帖子。像这样:
所以人们不会看到该字段(除非他们将 CSS 变成关闭,在这种情况下,他们会看到标签并将其留空),但垃圾邮件机器人会填写它。填充该字段的任何帖子都必须来自垃圾邮件机器人。
Add a new input field, label it "Please leave blank", hide it using CSS, and ignore the post if that field is filled in. Something like this:
So a human being won't see that field (unless they have CSS turned off, in which case they'll see the label and leave it blank) but a spam robot will fill it in. Any post with that field populated must be from a spam robot.
我不确定这是否是问题的原因,但您应该在该文件中取消设置
$_SESSION["captcha"]
,以便用户必须在每封电子邮件中键入一次验证码。 现在的情况是,他们可以在提交表单后点击刷新并快速发送所需数量的电子邮件。I'm not sure if this is the cause of your problem, but you should unset
$_SESSION["captcha"]
in that file so that the user has to type the captcha once per e-mail. The way it is now, they could hit refresh after submitting the form and send as many e-mails as they wanted very quickly.