2010-06-25 6 views
2

html 템플릿으로 메일을 보내려고합니다. 메일이 전송되었습니다. 하지만 그 메일에서 그 디자인을 찾을 수는 없습니다. 디자인과 함께 메일을 보내는 방법.PHP를 사용하여 HTML 템플릿을 메일로 보내는 방법은 무엇입니까?

메일은 내 html 템플릿에서 보이는 것과 정확히 일치해야합니다.

어떻게 수행하나요? 사려 깊은 조언.

미리 감사드립니다.

내 코드 :

$subject = "Hi this is subject"; 
$email = "[email protected]"; 
$message = "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<title>Super Qpon </title> 
</head> 
<link rel="stylesheet" href="../stylesheet/common.css" type="text/css"> 
<body> 

<div class="mainbodycontainer"> 
<div class="gift"> 
<div class="gft-top"></div> 
<div class="gft-bg"> 
<div class=""> 
<h1 class="title">Gift Coupon</h1> 
<div class="toppm"> 
<div class="coupon"> 
<div class="cop-top"></div> 
<div class="cop-bg"> 
<div> 
<table width="165" align="right" border="0" cellpadding="0" cellspacing="0"> 
<tr> 
<td width="81" class="t5">Coupon No :</td> 
<td width="84">SQ548555</td> 
</tr> 
</table> 
<div class="spacer"></div> 
</div> 
<div class="toppm"> 
<table width="500" border="0" cellpadding="0" cellspacing="0"> 
<tr> 
<td width="99" height="30">From</td> 
<td width="15" align="center">:</td> 
<td width="386">test</td> 
</tr> 
<tr> 
<td height="30">Amount</td> 
<td align="center">:</td> 
<td>$560</td> 
</tr> 
</table> 
<div class="spacer"></div> 
</div> 
<div class="toppm"> 
<table width="165" align="right" border="0" cellpadding="0" cellspacing="0"> 
<tr> 
<td width="81" class="t5">CODE NO :</td> 
<td width="84">SQ548555</td> 
</tr> 
</table> 
</div> 
<div class="spacer"></div> 
</div> 
<div class="cop-btm"></div> 
<div class="spacer"></div> 
</div> 
<div class="spacer"></div> 
</div> 
<div class="spacer"></div> 
</div> 
<div class="spacer"></div> 
</div> 
<div class="gft-btm"></div> 
<div class="spacer"></div> 
</div> 
<div class="spacer"></div> 
</div> 

</body> 
</html>"; 


$headers = 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
$headers .= 'From: SuperQpon <[email protected]>' . "\r\n"; 
mail($email,$subject,$message,$headers); 

답변

2

를 사용하여 당신의 인생을 많이 단순화 할 수 있습니다. 이렇게 (style = "background-color : # aefd34;").

나는 비슷한 문제에 직면했지만 스타일 속성에서 CSS를 정의하면 모두 괜찮 았어.

+0

당신의 CSS이 내 문제를 해결 너무. 감사합니다 – Fero

+0

@Fero : 천만에요. –

1

귀하의 문제가 여기에 거짓말을 할 수는 :

<link rel="stylesheet" href="../stylesheet/common.css" type="text/css">

이 스타일은 당신이 직장에 있음을 원하는 경우 이메일에 링크 될 필요가있다. 상대 경로는 컴퓨터/서버에있는 곳을 말하며 수신시 전자 메일을받을 수 없습니다.

편집

당신이 태그의 속성에서 모든 스타일을 정의한다면 더 좋을 것 http://postageapp.com/

+0

저에게 해답을 제공해 주시겠습니까? 나는 그것에 대해 약간 혼란 스럽다. 시스템에 스타일 시트가 들어있는 전체 서버 경로를 지정했습니다. 다른 선택의 여지가 있습니까? – Fero

+1

스타일 시트를 HTML로 참조하는 방법을 모르지만 스타일 시트를 첨부 파일로 포함 할 수는 있습니다. 또한 인라인으로 공급할 수도 있습니다. 아마도 (머리 부분에서) 일하는 것이 실제 HTML 파일, 즉, CSS를 넣어 postageapp – staticsan

+0

: <스타일 유형 = "텍스트/CSS를"> 는 // 여기에 –

0

전자 메일은 웹이 아니며 전자 메일 클라이언트의 HTML 렌더링 간의 차이가 웹 브라우저보다 훨씬 큽니다.하지만 원하는 모든 템플릿 시스템 (예 : Smarty)을 사용하여 전자 메일 콘텐츠를 생성 할 수 있습니다. 자세한 내용은 www.email-standards.org를보십시오. PHPMailer, SwiftMailer, Zend_Mail 등 렌더링 된 메시지를 보내려면 라이브러리를 사용하는 것이 좋습니다. 링크 된 스타일에서 인라인 스타일로 자동 변환 (내용의 전자 메일 호환성 비판)을 수행하려면 premailer

관련 문제