【问题标题】:my website contact form being used to send spoof emails我的网站联系表被用来发送恶搞电子邮件
【发布时间】:2017-11-18 13:12:04
【问题描述】:

我的托管服务提供商已与我联系,并说我设计的其中一个网站正在发送欺骗性电子邮件。做了一些研究,但我仍然不明白他们是如何/做什么来发送这些欺骗性电子邮件的。然而更重要的是,我应该如何处理这个问题,如果我尝试将这些“验证码”之一放在联系表单上,或者我应该更改我网站上的代码,会有所帮助吗?如下图所示:

<?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>

【问题讨论】:

    标签: php html validation email spoofing


    【解决方案1】:

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

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-15
    • 2020-05-20
    • 2019-10-03
    • 2020-12-07
    • 2011-08-12
    • 1970-01-01
    • 2011-05-30
    相关资源
    最近更新 更多