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



我是PHP的新手,我只是想阻止表单中的垃圾邮件。我有想出了如何使用以下代码进行蜜罐(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

使用此代码

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

最新更新