2015-09-01 4 views
0

По какой-то причине html не удается выполнить рендеринг в gmail, но отображает в hotmail.php email not reading html

Жизненно важно, чтобы gmail читал html, поэтому я задаюсь вопросом, какие изменения я должен внести в этот заголовок.

$from = "[email protected]"; 
    $headers = "From: bob at info.co <" .($from) . ">\n"; 
    $headers .= "Reply-To: ".($from) . "\n"; 
    $headers .= "Return-Path: ".($from) . "\n";; 
    $headers .= "MIME-Version: 1.0\n"; 
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\n"; 
    $headers .= "X-Priority: 3\n"; 
    $headers .= "X-Mailer: PHP". phpversion() ."\n"; 

Сообщение начинается как:

$message = '<html><body>'; 
    $message .= "<p>"; 

    $message .= "Hi $clean_fullName, <br><br>"; 
    $message .= " Well, I've looked at what you shared with me and I'm delighted to include my personal learning suggestions that I hope will help you achieve your startup goals."; 
    $message .= "<br><br>"; 
    $message .= "If they aren't quite what you're looking for, I take criticism better than most Entrepreneur Wizards 
    so please let me know by responding to this email and I'll take another look for you."; 
    $message .= "<br><br>"; 
    $message .= " 


    $message .="<br><br>Otherwise, happy learning!<br><br>"; 

    $message .= "<b>Total Learning time: </b>"; 
    // create an array of all the duration 
    $counter = array(); 

    foreach($data as $item) { 
     // add each duration item to the array after every iteration 
     array_push($counter, "{$item['duration']}"); 
    } 

    //record and display the result to the user 
    $message .= array_sum($counter); 

    $message .= "&nbsp;hours <br><br>"; 

    foreach($data as $item) { 
     $message .= "<b> 
     &#10139<a style='color:#FF6400; text-decoration: none' href='{$item['link']}'>{$item['title']}</a></b><br>"; 
     $message .= "Format: {$item['format']} <br>"; 
     $message .= "Cost: &#36;{$item['costs']} <br>"; 
     $message .= "Estimated Duration: {$item['duration']} hours<br>"; 
     $message .= "<br>"; 

    } 

    $message .= " If you have any questions, do not hesitate to reach out to us. <br><br>"; 
    $message .= "</p>"; 

    $message .= '</body></html>'; 

почта

mail($to,$subject,$message,$headers); 
+0

какой html ?????? –

+0

также в сообщении он начинается с «» и заканчивается ' – John

+0

но HTML отлично работает в Hotmail, но не GMAIL – John

ответ

1

Я все еще учусь :)

, но это должно работать

$from = "[email protected]"; 
$headers .= 'From: bob at info.co <$from>' . "\r\n"; 
$headers .= 'Reply-To: <$from> ' . "\r\n"; 
$headers .= 'Return-Path: <$from>' . "\r\n"; 
$headers .= 'MIME-Version: 1.0 ' . "\r\n"; 
$headers .= 'Content-Type: text/html; charset=ISO-8859-1' . "\r\n"; 
$headers .= 'X-Priority: 3' . "\r\n"; 
$headers .= 'X-Mailer: PHP". phpversion()' . "\r\n"; 

Ответа от комментариев

$message = '<html><body>'; 

и должно делать, как этот

$message .= '<html>'. "\r\n"; 
$message .= '<body>' . "\r\n"; 

У вас есть слишком много ошибок в написании недостающих точек пола т.д.,

, как я вижу ваш HTML теги не были открыты вообще.

есть варианты много, чтобы написать этот шаблон

1.

<?php 
// multiple recipients 
$to = '[email protected]' . ', '; // note the comma 
$to .= '[email protected]'; 

// subject 
$subject = 'Birthday Reminders for August'; 

// message 
$message = ' 
<html> 
<head> 
    <title>Birthday Reminders for August</title> 
</head> 
<body> 
    <p>Here are the birthdays upcoming in August!</p> 
    <table> 
    <tr> 
     <th>Person</th><th>Day</th><th>Month</th><th>Year</th> 
    </tr> 
    <tr> 
     <td>Joe</td><td>3rd</td><td>August</td><td>1970</td> 
    </tr> 
    <tr> 
     <td>Sally</td><td>17th</td><td>August</td><td>1973</td> 
    </tr> 
    </table> 
</body> 
</html> 
'; 

// To send HTML mail, the Content-type header must be set 
$headers = 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 

// Additional headers 
$headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "\r\n"; 
$headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n"; 
$headers .= 'Cc: [email protected]' . "\r\n"; 
$headers .= 'Bcc: [email protected]' . "\r\n"; 

// Mail it 
mail($to, $subject, $message, $headers); 
?> 

2.

$message.= 'blasldl asdas d asdas' . "\r\n"; 
$message.= ' sdfadasdasd dsad' . "\r\n"; 

U может изменить "\r\n" с $rn = "\r\n"; и использовать его быстро, как $rn

$message.= 'blasldl asdas d asdas' . $rn; 
$message.= ' sdfadasdasd dsad' . $rn; 

u можете попробовать эти решения и рассказать мне, что происходит. и не размещать все сообщения под управлением <p></p>

+0

и y на линии 4 u есть 2 точки с запятой –

+1

, пожалуйста, узнайте, что 'u' и' Я не слова. –

+1

@ Дагон жаль узнал. Больше никогда. Его плохая привычка от игр. –