2013-09-02 1 views
0

사용자가 전자 메일 요청을 보낼 때 제목과 메시지가 완벽 (이스케이프, 액센트, 기호 등)되지 않는 이유를 정말로 이해하지 못합니다. 이름과 성을 위해! 예를 들어 이름과 성의 액센트가있는 PHP 메일 기능

내 사용자 전체 이름 인 경우 : 내 고객 (MS 전망)에서 시험 è'ü-X-'zî 내가 참조 : 테스트 è'ü-X-'zî

을 이메일을 보낼 수

코드는 다음과 같습니다

$subject = stripslashes($subject); 
$message = stripslashes($message); 

$headers = "MIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n"; 

// problem here 
$headers .= "From: $user[name]<[email protected]>\nReply-to: $user[name]<$user[email]>\n\n"; 

@mail($email, $subject, $message, $headers); 

PS : DB에 저장되어있는 $ 사용자 [이름]하지 POST에, 내 모든 PHP 페이지에 내가 사용 UTF8 :

<meta charset="utf-8"> 

header('Content-Type: text/html; charset=utf-8'); 

mysqli_query($con, "SET NAMES 'utf8'") or die('Error (charset)'); 

어떻게 해결할 수 있습니까? 어쩌면 PHP 함수가 있을까요?

+0

[PHP의 메일 기능을 사용할 때받는 사람 이름에 특수 문자를 사용하는 방법] (http://stackoverflow.com/questions/7669668/how-to-use-special-characters-in-recipients-name- 사용중인 phps-mail-function), [php-charset 인코딩 메일 보내기] (http://stackoverflow.com/questions/7879784/send-mail-from-php-charset-encoding/7883771#7883771) – deceze

+0

예, 중복되었지만 검색했지만 아무 것도 발견되지 않았습니다. 이제는 이것이 내가해야 할 중복임을 알 수 있습니까? – ipel

답변

0

인코딩 문제를 다른 곳에서 이상적으로 해결해야하지만 iconv 함수를 사용하여 변환을 시도 할 수 있습니다.

iconv (string $in_charset , string $out_charset , string $str)

은 코드에 적용 할 수있다 : 당신이 알고있는 경우

iconv("ISO-8859-1", "UTF-8", $user['name'])

어려움은, 소스의 인코딩을 식별되어 다음 갈 수 있어요.