2011-12-20 13 views
1

私のhtml電子メールwelcome.tplファイルが整形されました。私はPutsMailでそれをテストし、以下のコードを処理して電子メールを送信しますが、HTMLはレンダリングされません。私が得ているのは、電子メール内の実際のHTMLソースコードです。HTMLメールが送信時にレンダリングされない

$mime_boundary = 'Multipart_Boundary_x'.md5(time()).'x';   
$headers = "MIME-Version: 1.0" . "\r\n"; 
$headers.= "Content-Type: multipart/alternative; boundary=" .$mime_boundary. "\r\n"; 
$headers.= "Content-Transfer-Encoding: 7bit\r\n"; 
$headers.= "From: <[email protected]>" . "\r\n"; 
$headers.= "X-Sender-IP: $_SERVER[SERVER_ADDR]" . "\r\n"; 
$headers.= "Date: ".date('n/d/Y g:i A') . "\r\n"; 
$headers.= "Reply-To: my" . "\r\n"; 

$subject='New Reg'; 

$body.= "{$mime_boundary}\n"; 
$body.= "Content-Type: text/html; charset=iso-8859-2\n"; 
$body.= "Content-Transfer-Encoding: 7bit\n\n"; 
$body.= $html_content; 
$body.= "\n\n"; 
$body.= "--{$mime_boundary}\n"; 

$html_content = file_get_contents('emails/welcome.tpl'); 
$body = str_replace("{Username}",$en['user'],$html_content); 
mail($en['email'], $subject, $body, $headers); 

答えて

3

使用して確認してください。

 
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; 

が、それはすべての境界が必要

1

ホープ " - " 先頭に追加、また最後の(終値)MIME境界ニーズ " - " が追加、そう

$body.= "[--]{$mime_boundary}\n"; 

に変更することでなければなりません最後に出現した上、すべてが、最後の出現に

$body.= "--{$mime_boundary}\n"; 

から

$body.= "--{$mime_boundary}--\n"; 

+0

これは間違いありませんか? '$ body =" - {$ mime_boundary} - \ n "; \t $ body。= "コンテンツタイプ:text/plain; charset = charset = us-ascii \ n"; \t $ body。= "コンテンツ転送エンコーディング:7ビット\ n \ n"; \t $ body。= $ text_content; \t $ body。= "\ n \ n"; \t $ body。= " - {$ mime_boundary} - \ n"; \t \t \t $ body。= " - {$ mime_boundary} - \ n"; $ body。= "コンテンツタイプ:text/html; charset = iso-8859- \ n"; \t $ body。= "コンテンツ転送エンコーディング:7ビット\ n \ n"; \t $ body。= $ html_content; \t $ body。= "\ n \ n"; \t $ body = " - {$ mime_boundary} \ n"; ' – acctman

+0

他の方法では、$ body = " - {$ mime_boundary}で始まります。 $ body。= " - {$ mime_boundary} - \ n"で終了します。 –

関連する問題