2016-09-30 34 views
0

HTML電子メールを送信します。私はmime.phpを使ってみましたが、うまく動作しませんでした。以下は私の作業テキストの電子メールコードです:SES SMTPインターフェイス経由のHTML電子メール - PEAR

<?php 
$subject="hello-test"; 
$body="<html><body><h1>message body</h1></body></html>"; 

$em_arr=array("[email protected]"); 
foreach ($em_arr as $to_address) 
{ 

require_once '/usr/local/share/pear/Mail.php'; 

$headers = array (
    'Content-Type:text/html;charset=UTF-8', 
    'From' => 'Test <[email protected]>', 
    'To' => $to_address, 
    'Subject' => $subject); 

$smtpParams = array (
    'host' => '<smtp host address>', 
    'port' => 587, 
    'auth' => true, 
    'username' => '<uname>', 
    'password' => '<password>' 
); 

// Create an SMTP client. 
$mail = Mail::factory('smtp', $smtpParams); 

// Send the email. 
$result = $mail->send($to_address, $headers, $body); 

if (PEAR::isError($result)) { 
    echo("Email not sent. " .$result->getMessage() ."\n"); 
} else { 
    echo("Email sent to ".$to_address."\n"); 
} 
} 
?> 

私はHTMLメールを送ることができる方法を教えてください。

答えて

1

私はにContentヘッダ行を交換しなければならなかった:

上記の間違いだった
'Content-Type' => "text/html; charset=UTF-8", 

。今はうまくいきます。

関連する問題