簡體   English   中英

PHP HTML電子郵件未發送

[英]PHP html email not sending

我的php電子郵件腳本似乎沒有發送,但我不明白為什么。 我也知道我的腳本存在某些安全缺陷,對此的任何建議都將不勝感激!

謝謝

  <?php

include('config.php');

$email1 = $_POST['email1'];

$id = $_POST['id'];
$fname = $_POST['fname'];
$firstname = $_POST['firstname'];
$surname = $_POST['surname'];


$to = '$email1';
$from = "$email"; 
    $subject = "SC - You Have a Reply"; 

        $body = "<html> 
  <body bgcolor=\"#FFFFFF\"> 
    <center> 
        <b>Dear $firstname</b> <br> 
        <font color=\"red\">You have a response, regarding your Ad on StudentClutter!</font> <br>
         <p> --------------------------------------------------------- </p>
         <b> $fname </b>
         <p> --------------------------------------------------------- </p>
         <p> ".stripslashes($_POST['body'])." </p>
         <br>
         <br>
         <br>
         <p> You can reply to them by email: $emailadd </p>
         <br>
         <br>
         <br>
         <p>Thank you for using studentclutter.com </p>
         <p> -- The Student Clutter Team </p>
    </center> 
  </body> 
</html>";

    // To send the HTML mail we need to set the Content-type header. 
    $headers = "MIME-Version: 1.0rn"; 
    $headers .= "Content-type: text/html; charset=iso-8859-1rn"; 
    $headers  .= "From: $from\r\n"; 

    // now lets send the email. 
    mail($to, $subject, $body, $headers); 

    echo "Message has been sent!"; 

 ?>

您在$email1周圍使用單引號,但沒有必要。 刪除引號,它應該可以正常工作。

像這樣

$to = $email1;

我建議您檢查一下PHPMailer類,該類提供了廣泛的功能以及安全性。 使用非常簡單,只需閱讀文檔即可。

更新

您還沒有在某些標題的末尾轉義return和換行符。 更改各行的結尾,如下所示:

\r\n";

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM