2012-06-19 5 views
2

저는이 메일 스크립트에 여전히 어려움을 겪고 있습니다. 이제는 모든 HTML을 마크 업하는 대신, 렌더링 된 HTML로 표시하는 것이 좋습니다.HTML 형식의 전자 메일이 올바르게 표시되지 않습니다.

<?php 
$mailheader .= "MIME-Version: 1.0\r\n"; 
$mailHeader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
$formcontent .="<table border='1'>"; 
foreach ($_POST as $field=>$value) 
{ 
    $formcontent.="<tr>"; 
    $formcontent .= "<td>$field:</td> <td>$value</td>"; 
    $formcontent.="</tr>"; 
} 
$formcontent .= '<tr><td>User-Agent: </td><td>'.$_SERVER['HTTP_USER_AGENT'].'</td>'; 
$formcontent .="</table>"; 


$recipient = "[email protected]*******.com"; 
$subject = "Event feedback form"; 
$mailheader = "From: [email protected]*******-events.co.uk\r\n"; 
$mailheader .= "Reply-To: $email\r\n"; 
$mailHeader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 


mail($recipient, $subject, $formcontent, $mailheader) or die("Failure!"); 
header("location:http://www.******-events.co.uk"); 
?> 
+0

어떻게 그 페이지를 여는거야? 브라우저 창 위로 드래그하거나 파일을 통해 여는 중입니까? 아니면 localhost/index.php를 사용하여 브라우징하고 있습니까? 건 그게 전부 – Sephallia

답변

0

HTML 이메일의 경우 PHP 클래스를 PHPMailer로 사용하고 싶습니다. 그리고 btw 메일 본문에 대한 전체 HTML 문서 태그 (html, head, body, etc ...)를 추가합니다.

1

따르 PHP의 문서 : 나는이 놓쳤다

HTML 태그를해야합니다

<?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); 
?> 
+0

을 (가정 당신은 순간에 로컬로 호스팅하고) - 나는에 모든 헤더를두고 여전히 이메일 양식 반환이있어 : <표 테두리 = '1'> 회사 :: 테스트 TD> 연락처 : 짐 홈즈 이메일 : 테스트 날짜 : 221122 Was_pre_event_support_thorough?이 5 Enough_pre_event_support? 5 Good_communication_throughout? 5 등, 당신이 일 수 전자 아이디어 .. 왜 전자 메일 클라이언트는 html로 렌더링되지 않습니까? – Jimbly2

+0

그것은 당신이 거기에 PHP 파일에 넣어 말을하지 않습니다. 그들이 포함되어 있다고 생각하는 곳은 어디입니까? – maxhud

+0

처음 세 줄? Jimbly2

0

: 모든 사람의 시간과 입력

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

감사하지만 짐

관련 문제