2011-07-28 3 views
2

가능한 중복을 보여줍니다 이메일을 보내 PHP를 사용하여
Sending HTML email from PHPHTML 이메일은 코드

.

나는 그것이 HTML 기반이되기를 원하지만,받은 편지함에서 이메일을 받으면 그냥 원시 코드를 보여줄뿐입니다.

텍스트 대신 HTML로 interprited 할 수 있습니까?! 모든 사람을 위해

이 문서에서 코드를

<?php 
//The email of the sender 
$email = $_POST['email']; 
//The message of the sender 
$message = "<html></html>"; 
//The subject of the email 
$subject = "Fanshawe Student Success"; 
$extra = $email."\r\nReply-To: ".$email."\r\n"; 
mail($email,$subject,$message,$extra); 
?> 
+0

어때? * 당신 * 우리가 당신이 말하는 것을 알 수 있도록 몇 가지 코드를 보여주십시오. – zzzzBov

+0

http://www.google.com/search?q=html+e-mail+php 및 http://php.net/mail (예 # 4) – ceejayoz

+0

이메일을 보내는 곳의 코드를 표시해야합니까? – Griwes

답변

4

당신이가는 메일로 전달되어야한다 :

// multiple recipients 
$to = '[email protected]'; 

//subject 
$subject = 'Email Template for Lazy People'; 

//message body 
$message = " 
<html> 
<head> 
    <title>My Title</title> 
</head> 
<body> 
    <div> 
     <b>My email body</b> 
    </div> 
</body> 
</html> 
"; 

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

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

고마워, 우리는 메일 스크립트를 읽었을 때 결코 헤더를 넘기지 않으므로 나에게 그렇게 분명하지 않았다. 그러나 크게 감사! –

+0

이것은 나를 도왔습니다. 고맙습니다 – mutiemule