php
  • html
  • email
  • 2012-09-02 25 views 0 likes 
    0

    這是在bluehost上 - 我曾嘗試發送到其他客戶端,除了gmail,我仍然得到同樣的問題:我的所有html都顯示爲明文/標籤。沒有被渲染成html。PHP腳本通過電子郵件發送HTML只輸出明文

    $to = '###@gmail.com'; 
    
        $headers = 'MIME-Version: 1.0' . "\r\n"; 
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
        $headers .= "From: $from \r\n"; 
    
    
        $headers = array(
    
        'From' => "###@####.com", 
    
        'Cc' => "####@gmail.com", 
    
        'Subject' => "Your Reminder From Remindmeto.org", 
    
        ); 
    
    
    
        $body = '<html><body>'; 
        $body .= '<h1>From the mists of memory I speak...</h1>'; 
        $body .= "$image"; 
        $body .= '</body></html>'; 
    
    
    
        $mail = Mail::factory("mail"); 
    
        $mail->send($to, $headers, $body); 
    
    +0

    是什麼,你收到消息的消息來源是什麼樣子?答案將在那裏。 –

    +0

    此外,我注意到你正在用'\ r \ n'構建一個頭字符串,但是然後將你的頭重新聲明爲一個數組。你的'Mail :: factory()'期望哪一個?如果它期望一個字符串,但最終給它一個數組,那就是你的問題。 –

    +0

    [從PHP發送HTML電子郵件]可能的副本(http://stackoverflow.com/questions/3058897/sending-html-email-from-php) – mario

    回答

    0

    您正在設置您的標題兩次。改成這樣:

    $headers = 'MIME-Version: 1.0' . "\r\n"; 
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
    $headers .= "From: $from \r\n"; 
    $headers .= "Cc: ####@gmail.com \r\n"; 
    $headers .= "Subject: Your Reminder From Remindmeto.org \r\n"; 
    

    ,擺脫了陣列部分:)

    相關問題