メールが正しく受信されました。安全のために私はrecaptcha秘密鍵を隠しましたが、この部分はうまくいきます。電子メールを受信すると、件名の特殊文字が正しく表示されます。ただし、フランス語のアクセントがメッセージ(たとえばéèàç
)に送信されている場合は、次のように表示されます(éèà ç
)。これはフランス語のウェブサイトなので、これは本当の問題です。私はメール機能でutf8_encode($message)
を試しましたが、役に立たないです。私は他のstackoverflowの投稿を見たが、役に立たなかった。メッセージの中では、この部分はContent-type: text/plain; charset=UTF-8'
と表示されます。これは避けられますか?私のメール機能は、件名にutf8文字を表示するが、メッセージ自体には表示されないのはなぜですか?
<?php
if(isset($_POST['valider'])) {
$url = 'https://www.google.com/recaptcha/api/siteverify';
$privateKey = "secret";
$response = file_get_contents($url."?secret=".$privateKey."&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR']);
$data = json_decode($response);
if(isset($data->success) AND $data->success==true){
$rusty = '[email protected]';
$destinataire = $_POST["email"];
$message = utf8_encode(wordwrap($_POST['message']));
$subject = "Question pour la méthode EtVoilà";
$headers = 'From:' . $destinataire."\n";
$header_ = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n";
if(mail($rusty,'=?UTF-8?B?'.base64_encode($subject).'?=',$message,$header_ . $headers)) {
header('Location: index.php?MessagePass=True');
} else {
header('Location: index.php?MessageError=True');
}
}
}
?>
言及するのを忘れた、HTMLページがUTF-8(<メタ文字コード= "UTF-8"> <メタHTTP-当量= "Content-Typeの" コンテンツ= "text/htmlの中で、=文字セットutf-8 "/> ) –