我的网站联系表被用来发送欺骗性电子邮件

问题描述:

我的主机提供商已经与我联系,并说我设计的网站之一是发送欺骗性电子邮件。做了一点研究,但我还是不太了解他们发送这些恶搞电子邮件的方式。但更重要的是,我应该如何处理这个问题,如果我尝试在联系表单上放置其中一个“验证码”,或者是否应更改我网站上的代码,是否会有所帮助?其中显示如下:我的网站联系表被用来发送欺骗性电子邮件

<?php 

$EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); 
$EmailTo = "***"; 
$Subject = "Message to A R C Products"; 
$Name = Trim(stripslashes($_POST['Name'])); 
$Address = Trim(stripslashes($_POST['Address'])); 
$Telephone = Trim(stripslashes($_POST['Telephone'])); 
$Message = Trim(stripslashes($_POST['Message'])); 



// prepare email body text 


$headers = 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 

$Message = " 
Name:$Name 
Address: $Address 
Telephone: $Telephone 
$Message"; 

// send email 
$success = mail($EmailTo, $Subject, $Message, $headers); 

// redirect to success page 
if ($success){ 
    print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.html\">"; 
} 
else{ 
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">"; 
} 
?> 


<h2><strong>Contact Us</strong></h2> 
         <form method="POST" action="contact.php"> 
         <br/> 
      <p style="margin-top: 0;">Fields marked (*) are required</p> 

      <p style="margin-top: 0;">Your Email:* <br/> 
      <input type="text" name="EmailFrom"> 
      <p style="margin-top: 0;">Name:* <br/> 
      <input type="text" name="Name"> 
      <p style="margin-top: 0;">Address:<br/> 
      <input type="text" name="Address"> 
      <p style="margin-top: 0;">Telephone:<br/> 
      <input type="text" name="Telephone"> 
      <p style="margin-top: 0;">Message:*<br/> 
      <TEXTAREA NAME="Message" ROWS=6 COLS=40> 
      </TEXTAREA> 
      <p style="margin-top: 0;"><input type="submit" name="submit" value="Submit"> 

      </form> 

看看filter_input清理输入数据。我也不会使用表格中的电子邮件作为发件人地址。

$EmailFrom = filter_input(INPUT_POST,'EmailFrom', FILTER_SANITIZE_EMAIL); 
+0

非常感谢您的帮助:)将不久尝试此,对于任何不真正了解肇事者正在做这条本解释https://www.thesitewizard.com/php/protect-script - 从电子邮件,injection.shtml –