악센트가있는 제목이 포함 된 전자 메일을 보내는 데 문제가 있습니다. 나는 모든 곳에서 수색했으며 모든 해결책이 효과가 없습니다.액센트가있는 PHP 메일
$headers = "MIME-Version: 1.0" . $endl;
$headers .= 'Content-type: text/html; charset="iso-8859-1"' . $endl;
$headers .= 'Content-Transfer-Encoding: 8bit';
:
나는 캐릭터, 주제, 아마 명령 줄 스크립트
$res = shell_exec(sprintf("php mail.php %s %s %s %s",
escapeshellarg($email->sender),
escapeshellarg($receiver->email),
escapeshellarg($email->subject),
escapeshellarg($email->message)
));
그리고 메일의 헤더를 통해 전송, ISO-8859-1으로 인코딩이 결과로, 나는 ???? 주제에
참고 : Windows에서 테스트, 로컬 호스트
샘플 코드
testmail.php
<?php
$sender = "[email protected]";
$receiver = "[email protected]";
$subject = "Accentued éàèçô letters";
$msg = "Accentued éàèçô letters";
shell_exec(sprintf('LANG="fr_FR.iso88591"; php mail.php %s %s %s %s > /dev/null 2>/dev/null &',
escapeshellarg($sender),
escapeshellarg($receiver),
escapeshellarg($subject),
escapeshellarg($msg)
));
?>
mail.php
<?php
if ($argc!=5) exit;
$sender = $argv[1];
$receiver = $argv[2];
$subject = $argv[3];
$msg = $argv[4];
$endl = "\r\n";
//HTML header
$headers = "From: $sender" . $endl;
$headers .= "MIME-Version: 1.0" . $endl;
$headers .= "Content-type: text/html; charset=iso-8859-1" . $endl;
$headers .= 'Content-Transfer-Encoding: 8bit';
$msg = "
<html>
<head>
<title></title>
</head>
<body>
$msg
</body>
</html>
";
$receiver = explode(',', $receiver);
foreach ($receiver as $rec)
{
mail($rec, $subject, $msg, $headers);
sleep(5);
}
?>
실행 : php testmail.php Linux에서 테스트되었습니다.
해결 이 문제에 대한 올바른 해결책은 base64_encode
'=?UTF-8?B?' . base64_encode($subject) . '?=';
http://stackoverflow.com/questions/1719149/send-emails-with-international-accent-and-special-characters 허용되는 답변 하단을 참조하십시오. – pbond
** 아마도 인코딩 되었습니까? ** 적절한 구두점과 악센트는 사용되는 인코딩에 의존합니다 !! _probably_ 좋지 않습니다! 사용중인 인코딩이 무엇인지 확실히 알아야합니다. – Zuul
@ peterbond : 시도했다. 먼저 사용해야하는 콘텐츠 유형 text/plain이 아닙니다.둘째, 시도 base64 인코딩하지만 행운을 빕니다. 문제는 명령 줄 인코딩에 있으며 Windows에서는 Windows-1252입니다. 다른 시스템에서는 다를 수 있습니다. –