我注意到我创建的表单上有许多垃圾邮件注册,用于在下载产品手册之前捕获客户信息。
我试图通过验证字段和实施Google Re-captcha来限制垃圾邮件参与者的数量。 但是,这还没有阻止我仍然收到的垃圾邮件数量。请参阅PHP表单。下面。
<?php
// grab recaptcha library
require_once "recaptchalib.php";
$name=$_POST['fname'];
$email=$_POST['email_from'];
$phone=$_POST['phone'];
$city=$_POST['city'];
$content=$_POST['comments'];
$to ='person@email.co.uk';
$subject ='Brochure Enquiry';
$headers = "From: " . strip_tags($email) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= '<table rules="all" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>" .$name. "</td></tr>";
$message .= "<tr style='background: #eee;' ><td><strong>Email:</strong> </td><td>" . $email. "</td></tr>";
$message .= "<tr style='background: #eee;'><td><strong>Phone:</strong> </td><td>" . $phone . "</td></tr>";
$message .= "<tr style='background: #eee;'><td><strong>City:</strong> </td><td>" .$city. "</td></tr>";
$message .= "<tr style='background: #eee;'><td><strong>Message:</strong> </td><td>" .$content. "</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
//This method sends the mail.
if(mail($to,$subject,$message,$headers))
//This creates the csv file.
if($error == '')
{
$file_open = fopen("downloadcsv.csv", "a");
$no_rows = count(file("downloadcsv.csv"));
if($no_rows > 1)
{
$no_rows = ($no_rows - 1) + 1;
}
$form_data = array(
'name' => $name,
'email' => $email,
'phone' => $phone,
'city' => $city,
'content' => $content
);
fputcsv($file_open, $form_data);
}
// secret key - removed for privacy
$secret = "-----------------------------";
// empty response
$response = null;
// check secret key
$reCaptcha = new ReCaptcha($secret);
// if submitted check response
if ($_POST["g-recaptcha-response"]) {
$response = $reCaptcha->verifyResponse(
$_SERVER["REMOTE_ADDR"],
$_POST["g-recaptcha-response"]
);
}
//This is the brochure link.
{
header('Location:http://www.brochure.de/pdf/brochure_2018.pdf');
}
?>
</div>
</div>