从表单提交中排除特定的电子邮件地址

时间:2012-11-20 05:29:08

标签: email block spam-prevention

我是PHP的新手,我只是想阻止我的表单中的垃圾邮件。我有 想出了如何使用以下代码执行honeypot(url字段) 阻止90%的垃圾邮件 - 但这一个令人恼火的电子邮件通过 (让我们称他们为redacted@example.com)。我想写一行 我的表单中的代码,只是说电子邮件字段是否填写了文本 'redacted@example.com',然后不要通过表格。有没有人可以帮我这么做?

// if the url field is empty
// if(isset($_POST['url']) && $_POST['url'] == ''){

// then send the form to your email
// mail( 'myemail@me.com', 'Contact Form', print_r($_POST,true) );
// }

// otherwise, let the spammer think that they got their message through

1 个答案:

答案 0 :(得分:1)

使用此代码

if(isset($_POST['url']) && $_POST['url'] == '') {
    if ($_POST['email'] != 'dukang2004@yahoo.com') {
        // then send the form to your email
         mail( 'myemail@me.com', 'Contact Form', print_r($_POST,true) );
    }
}