php mail() korean characters
Moderator: General Moderators
php mail() korean characters
I have to send korean text through php mail(). For somereason it goes all funky. I get stuff like this: �ック�ャ �ケ�ー�イ昤 �ャ�、� �昤 instead of this: 미쉬 비밀번호 재설정 암호. I've tried sending the headers with Content-type: text/html; charset=iso-8859-1 and charset=EUC-KR and charset-UTF-8 and using mb_encode_mimeheader, but nothing seems to work. Anyone know how to solve this?
Last edited by gth759k on Sun Apr 25, 2010 8:44 pm, edited 1 time in total.
Re: php main() korean characters
The mail content type needs to match the data content type.
Where are you getting those characters from?
Where are you getting those characters from?
Re: php mail() korean characters
My friend is doing the translating in a email. I send him an email with the english and he sends me the email back with translations. Then I put the translations in the database with a regular html form and we have a button on our site that allows the user to select between english or korean. It works for having a multilingual site, but when we need to send a sytem email like for resetting your password, the email needs to be in korean, so my password reset form takes the users email address and sends them a reset code in an email. Its the title of that email that is getting garbled. The reset form just takes the translation out of the database for the subject parameter like:
$languagesql = "SELECT korean_translation FROM languages WHERE id = 'password_reset_subject'";
$languageresult = mysql_query($languagesql) or die(mysql_error());
$languagedata = mysql_fetch_array($languageresult, MYSQL_ASSOC);
$to = $_POST['email_address'];
$subject = $languagedata['korean_translation'];
$message = $security_code;
$headers = "From: support@domain.co.kr\r\n" ;
$headers .= "Reply-To: support@domain.co.kr\r\n";
$headers .= "Content-type: text/html; charset=EUC-KR\r\n";
mail($to, $subject, $message, $headers);
The email that gets sent has a subject like: �ック�ャ �ケ�ー�イ昤 �ャ�、� �昤, but if I were to just echo $languagedata['korean_translation'] within the webpage, it displays the korean just fine. I'm stumped.
$languagesql = "SELECT korean_translation FROM languages WHERE id = 'password_reset_subject'";
$languageresult = mysql_query($languagesql) or die(mysql_error());
$languagedata = mysql_fetch_array($languageresult, MYSQL_ASSOC);
$to = $_POST['email_address'];
$subject = $languagedata['korean_translation'];
$message = $security_code;
$headers = "From: support@domain.co.kr\r\n" ;
$headers .= "Reply-To: support@domain.co.kr\r\n";
$headers .= "Content-type: text/html; charset=EUC-KR\r\n";
mail($to, $subject, $message, $headers);
The email that gets sent has a subject like: �ック�ャ �ケ�ー�イ昤 �ャ�、� �昤, but if I were to just echo $languagedata['korean_translation'] within the webpage, it displays the korean just fine. I'm stumped.
Last edited by gth759k on Sat Jul 24, 2010 11:34 pm, edited 1 time in total.
Re: php mail() korean characters
I just tried putting the korean email subject in a hidden input field of the password reset form, which didn't work either.
in the form:
<input type="hidden" name="hiddensubject" value="'.$languagedata['korean_translations'].'">
in the handler script:
$subject = $_POST['hiddensubject'];
in the form:
<input type="hidden" name="hiddensubject" value="'.$languagedata['korean_translations'].'">
in the handler script:
$subject = $_POST['hiddensubject'];
Re: php mail() korean characters
What encoding is the web page using? In Firefox you can right-click anywhere on the page, hit Page Info, and see the Encoding mentioned.gth759k wrote:but if I were to just echo $languagedata['korean_translation'] within the webpage, it displays the korean just fine.
Re: php mail() korean characters
its UTF-8, which I tried as a header and it still didn't work
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";