[wp-trac] Re: [WordPress Trac] #209: Subject line of sent e-mails
is not UTF-8
WordPress Trac
wp-trac at lists.automattic.com
Sat Mar 11 06:54:38 GMT 2006
#209: Subject line of sent e-mails is not UTF-8
----------------------------+-----------------------------------------------
Id: 209 | Status: assigned
Component: Administration | Modified: Sat Mar 11 06:54:38 2006
Severity: trivial | Milestone:
Priority: normal | Version: 1.2
Owner: ryan | Reporter: crculver
----------------------------+-----------------------------------------------
Changes (by kpumuk):
* cc: Sebbi, cal, Citizen K, sjmurdoch => Sebbi, cal, Citizen K,
sjmurdoch, kpumuk
Comment:
I have same problem and solved it in following way (version 2.0.2):
{{{
if ( !function_exists('wp_mail') ) :
function wp_mail($to, $subject, $message, $headers = '') {
if( $headers == '' ) {
$headers = "MIME-Version: 1.0\n" .
"From: wordpress@" . preg_replace('#^www\.#', '',
strtolower($_SERVER['SERVER_NAME'])) . "\n" .
"Content-Type: text/plain; charset=\"" .
get_settings('blog_charset') . "\"\n";
}
return @mail($to, wp_encodeMimeSubject($subject), $message,
$headers);
}
function wp_encodeMimeSubject($s) {
$lastspace=-1;
$r="";
$buff="";
$mode=1;
for ($i=0; $i<strlen($s); $i++) {
$c=substr($s,$i,1);
if ($mode==1) {
$n=ord($c);
if ($n & 128) {
$r.="=?" . get_settings('blog_charset') . "?Q?";
$i=$lastspace;
$mode=2;
} else {
$buff.=$c;
if ($c==" ") {
$r.=$buff;
$buff="";
$lastspace=$i;
}
}
} else if ($mode==2) {
$r.=wp_qpchar($c);
}
}
if ($mode==2) $r.="?=";
return $r;
}
function wp_qpchar($c) {
$n=ord($c);
if ($c==" ") return "_";
if ($n>=48 && $n<=57) return $c;
if ($n>=65 && $n<=90) return $c;
if ($n>=97 && $n<=122) return $c;
return "=".($n<16 ? "0" : "").strtoupper(dechex($n));
}
endif;
}}}
--
Ticket URL: <http://trac.wordpress.org/ticket/209>
WordPress Trac <http://wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list