-5

我收到这种形式的电子邮件:

"<span style="color:red;"> blablabla text goes here </span>"

代替

"blablabla text goes here"

红色的。任何类型的 html 都作为代码发送出去......关于如何解决这个问题的任何想法?提前致谢

if(isset($_REQUEST['Message']) && $_REQUEST['Message']!="")
    {
        $header="From: ".$_REQUEST['FromName']."<".$_REQUEST['FromEmail'].">\r\n" .
        'X-Mailer: PHP/' . phpversion() . "\r\n" .
        "MIME-Version: 1.0\r\n" .
        "Content-Type: text/html; charset=iso-8859-1" . "\r\n".
        "Content-Transfer-Encoding: 8bit\r\n\r\n";
        $to=explode(",",$_REQUEST['Recipients']);
        for($i=0;$i<count($to);$i++)
        {
            $x=explode("<",$to[$i]);
            $x=explode(" ",$x[0]);
            $firstname=$x[0];
            mail($to[$i],$_REQUEST['Subject'],str_replace("\$firstname",$firstname,$_REQUEST['Message']),$header);
            //
        } 
4

1 回答 1

1

示例代码如下。

<? 
    //change this to your email. 
    $to = "m@maaking.com"; 
    $from = "m2@maaking.com"; 
    $subject = "Hello! This is HTML email"; 

    //begin of HTML message 
    $message = "<html> 
  <body bgcolor=\"#DCEEFC\"> 
    <center> 
        <b>Looool!!! I am reciving HTML email......</b> <br> 
        <font color=\"red\">Thanks Mohammed!</font> <br> 
    </center> 
      <br><br>*** Now you Can send HTML Email <br> Regards<br>MOhammed Ahmed - Palestine 
  </body> 
</html>"; 
   //end of message 

    // 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"; 
    //options to send to cc+bcc 
    //$headers .= "Cc: maa@p-i-s.com"; 
    //$headers .= "Bcc:email@maaking.com"; 

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

    echo "Message has been sent....!"; 
?>
于 2012-10-16T06:46:15.653 回答