cuongvt Posted May 29, 2009 Share Posted May 29, 2009 Hi all I'm using below function to send Japanese mail, mail clients such as outlook etc displayed Japanese text withou problems but if I viewed JP mail via web-based mail such as Gmail, the JP subject is normally displayed, however the JP body still base64 encoded strings, it still was not decoded yet. Could anyone tell me solution to solve this? ======================================= private static function _sendPc( $from, $to, $subject, $body, $contentType, $charSet="shift_jis", $header="", $parameter=""){ Debugger::snap(); //make header $headers = "From: $from\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-type: $contentType; charset=ISO-2022-JP\n"; //$headers .= "Content-type: $contentType; charset=SHIFT_JIS\n"; //$headers .= "Content-Transfer-Encoding: base64"; $headers .= "Content-Transfer-Encoding: quoted-printable"; // add header to mail if( strlen( $header ) > 0 ){ $headers .= "\n"; $headers .= $header; } //make parameter $parameters = $parameter; //make subject $subject = '=?ISO-2022-JP?B?'.base64_encode(mb_convert_encoding($subject, 'ISO-2022-JP', 'AUTO' )).'?='; //$subject = '=?SHIFT_JIS?B?'.base64_encode($subject).'?='; //$body = base64_encode($body); $body = mb_convert_encoding( $body, 'ISO-2022-JP', "AUTO"); // a,[email protected] こんなEMAILアドレスがたまにあるための回避策 $pos1 = strpos($to, ","); $pos2 = strpos($to,"<"); if( $pos1 !== FALSE && $pos2 === FALSE ){ $to = "<" . $to .">"; } if( $parameters != null && strlen( $parameters ) > 0 ) mail( $to, $subject, $body, $headers, $parameters ); else mail( $to, $subject, $body, $headers,"-f" . $from ); Debugger::debug( "sended" ); return true; } Thanks and regards, Link to comment https://forums.phpfreaks.com/topic/160098-mail-body-not-decoded-by-base64_decode/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.