Ben kullanmak PEAR Mail_Mime ve mb_encode_mimeheader konuyu kodlamak. Burada çalışan bir fonksiyon örneği:
<?php
function mail_html($from, $to, $subject, $message_html, $headers = array()) {
require_once "Mail.php";
require_once 'Mail/mime.php';
$smtp = Mail::factory('smtp',
array (
'host' => 'smtp.example.com',
'auth' => true,
'username' => 'user@example.com',
'password' => 'password'));
if(function_exists('mb_internal_encoding'))
mb_internal_encoding('UTF-8');
if(function_exists('mb_encode_mimeheader'))
$subject = mb_encode_mimeheader($subject,"UTF-8", "B", "\n");
$h = array();
$h['From'] = "$from";
$h['Bounce'] = "$from";
$h['Reply-To'] = "$from";
$h['Return-Path'] = "$from";
$headers['Subject'] = $subject;
$headers = array_merge($h, $headers);
$mime = new Mail_mime();
$mime->setHTMLBody($message_html);
$body = $mime->get(array('html_charset' => 'UTF-8', 'html_encoding' => '8bit', 'head_charset'=> 'UTF-8'));
$hdrs = $mime->headers($headers);
$mail = $smtp->send($to, $hdrs, $body);
if (PEAR::isError($mail))
echo 'error', 'Unable to send email';
else
echo "Sent email to $to from $from";
}
?>