2012-05-04 7 views
4

私はtext/htmlフォーマットの収入電子メールのコンテンツタイプをクライアント/ユーザマシンのデフォルトのフォントスタイルとサイズに設定していると仮定しています。 User Pear Mailコンテンツタイプにどのように追加しますか?私が送ったすべての例では、MIMEタイプの添付ファイルでコンテンツタイプを追加することしか示していません。郵便受けにコンテンツタイプを追加

また、メールクライアントのフォントスタイルとサイズをデフォルトにする別の方法がある場合、私はそれを知りたいと思います。

はこの作品

$headers = "MIME-Version: 1.0\r\n"; 
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 

現在のメールコード

$from = "[email protected]"; 
$to = $SendTo; 
$subject = "Contact : " . $uxGlobalLocation; 
$body = $Bodycopy; 
$host = "mail.set.co"; 
$username = "[email protected]"; 
$password = "empty00"; 
$headers = array ('From' => $from, 
'To' => $to, 
'Subject' => $subject); 
$smtp = Mail::factory('smtp', 
array ('host' => $host, 
'auth' => true, 
'username' => $username, 
'password' => $password)); 
$mail = $smtp->send($to, $headers, $body); 
if (PEAR::isError($mail)) { 
echo("<p>" . $mail->getMessage() . "</p>"); 
} else { 
header ('Location: /'); 
exit(); 
} 

EDIT可能な答え

$headers = array ('From' => $from, 
'To' => $to, 
'Subject' => $subject, 
'Content-Type' => 'text/html; charset=iso-8859-1', 
'MIME-Version' => '1.0'); 

答えて

8

を追加したいと思います。 $ headers配列の最後の項目は\ r \ n \ r \ nである必要があります。

<?php 
require_once "Mail.php"; 
$from = "Web Master <[email protected]>"; 
$replyto = "Education Dept. <[email protected]>"; 
$to = "<[email protected]>"; 
$subject = "Test email using PHP SMTP"; 
$body = "<p>Test HTML</p><p>This is a test email message</p>"; 

$host = "smtp.example.com"; 
$username = "[email protected]"; 
$password = "****************"; 

$headers = array ('From' => $from, 
    'To' => $to, 
    'Subject' => $subject, 
    'Reply-To' => $replyto, 
    'MIME-Version' => "1.0", 
    'Content-type' => "text/html; charset=iso-8859-1\r\n\r\n"); 

$smtp = Mail::factory('smtp', 
    array ('host' => $host, 
    'auth' => true, 
    'username' => $username, 
    'password' => $password)); 

$mail = $smtp->send($to, $headers, $body); 

if (PEAR::isError($mail)) { 
    echo("<p>" . $mail->getMessage() . "</p>"); 
} else { 
    echo("<p>Message successfully sent!</p>"); 
} 
?> 
関連する問題