我想知道以下代码是否会阻止我的 HTML 电子邮件表单中的电子邮件标头注入?
(我从另一个网站引用了这段代码。)
我的代码如下。
$SpamErrorMessage = "Whoa, slooooooow doooown";
if (preg_match("/http/i", "$first")) {echo "$SpamErrorMessage"; exit();}
if (preg_match("/http/i", "$last")) {echo "$SpamErrorMessage"; exit();}
if (preg_match("/http/i", "$email")) {echo "$SpamErrorMessage"; exit();}
if (preg_match("/http/i", "$message")) {echo "$SpamErrorMessage"; exit();}
/* Email Variables */
$emailSubject = 'You have received an inquiry from your website';
$webMaster = 'info@3elementsreview.com';
/* Data Variables */
$first = Trim(stripslashes($_POST['First']));
$last = Trim(stripslashes($_POST['Last']));
$email = Trim(stripslashes($_POST['E-Mail']));
$message = Trim(stripslashes($_POST['Message']));
$body = <<<EOD
<span style="color:#454545; font-weight:bold; font-size:1.6em;">$first</span><br>
<span style="color:#454545; font-weight:bold; font-size:1.6em;">$last</span><br>
<span style="color:#454545; font-weight:bold; font-size:1.6em;">$email</span><br>
<br>
<span style="color:#252525; font-size:1.4em;">$message</span><br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);