2010-01-28 158 views
2

每次我使用這個腳本時,我會在電子郵件中出現隨機符號。它是標題中的字符類型嗎?如果是的話,什麼是正確的字符類型使用?PHP HTML電子郵件字符問題

$icontent = nl2br($icontent); 

    $str = "<html>"; 
    $str .= "<head>"; 
    $str .= "<title>Mail</title>"; 
    $str .= "<style type='text/css'>"; 
    $str .= "<!--"; 

    $str .= "body {"; 
    $str .= " background-color:#FFFFFF;"; 
    $str .= " margin:0px;"; 
    $str .= " font-family:Arial;"; 
    $str .= " padding:0px;"; 
    $str .= "}"; 

    $str .= "</style></head>"; 

    $str .= "<body>"; 
    $str .= "<center>"; 

    $str .= "<div class='logo'>"; 
    $str .= "<span style='font-size:12px'>$subject</span><br />"; 
    $str .= "<span style='font-size:10px; font-weight:normal'>" . date("d M Y H:i") . "</span><br />"; 
    $str .= "</div>"; 

    $str .= "<div class='content'>"; 
    $str .= $icontent; 
    $str .= "</div>"; 

    $str .= "<div class='credit'>"; 
    $str .= "This e-mail is confidential."; 
    $str .= "</div>"; 

    $str .= "</center>"; 
    $str .= "</body>"; 
    $str .= "</html>"; 

    $headers = "MIME-Version: 1.0rn"; 
    $headers .= "Content-type: text/html; charset=iso-8859-1rn"; 
    $headers = "From: Us <[email protected]>\r\n"; 
    $headers .= "Content-type: text/html\r\n"; 

    mail($to, $subject, $str, $headers); 

我將使用Fedora 10的

由於添加IM提前

回答

2
$headers = "MIME-Version: 1.0\r\n"; // backslashes missing 
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; // backslashes missing 
$headers .= "From: Us <[email protected]>\r\n"; // "." missing before "=" 
$headers .= "Content-type: text/html\r\n"; 

的probleme是,你只發送的最後2頭。

+0

哦是的,剛纔看到固定它:但同樣的問題不幸的是:( – 2010-01-28 07:37:27

+0

它的工作棒極了..謝謝 – 2010-01-28 07:54:10

1
$str .= "<head>"; 
    $str .= "<title>Mail</title>"; 
    $str .= "<style type='text/css'>"; 

// This HTML comment is never closed: 
    $str .= "<!--"; 

    $str .= "body {"; 
    $str .= " background-color:#FFFFFF;"; 
    $str .= " margin:0px;"; 
    $str .= " font-family:Arial;"; 
    $str .= " padding:0px;"; 
    $str .= "}"; 

// add this line:  
    $str .= "-->"; 

    $str .= "</style></head>"; 
+0

那裏等待它。它剛剛在複製和粘貼取出加1井spoted。 – 2010-01-28 07:55:12