以下のPHPスクリプトでフォームメールを送っているのですが、
受取側でどうしても文字化けしてしまいます。
どうか教えて下さい。
<?php header("Content-type: text/html; charset=UTF-8"); mb_language("Japanese"); mb_internal_encoding("UTF-8"); $to = '△@〇□'; // please change this email id $errors = array(); // print_r($_POST); // Check if name has been entered if (!isset($_POST['name'])) { $errors['name'] = 'お名前を記入してください。'; } // Check if email has been entered and is valid if (!isset($_POST['email']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { $errors['email'] = 'メールアドレスを記入してください。'; } //Check if message has been entered if (!isset($_POST['message'])) { $errors['message'] = '問い合わせ内容を記入してください。'; } $errorOutput = ''; if(!empty($errors)){ $errorOutput .= '<div class="alert alert-danger alert-dismissible" role="alert">'; $errorOutput .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>'; $errorOutput .= '<ul>'; foreach ($errors as $key => $value) { $errorOutput .= '<li>'.$value.'</li>'; } $errorOutput .= '</ul>'; $errorOutput .= '</div>'; echo $errorOutput; die(); } $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $from = $email; $subject = 'お問合せ'; $body = "From: $name\n E-Mail: $email\n Message:\n $message"; //send the email $result = ''; if (mail ($to, $subject, $body)) { $result .= '<div class="alert alert-success alert-dismissible" role="alert">'; $result .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>'; $result .= 'お問合せありがとうございます。後ほどメールで回答差し上げますので今しばらくお待ちください。'; $result .= '</div>'; echo $result; die(); } $result = ''; $result .= '<div class="alert alert-danger alert-dismissible" role="alert">'; $result .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>'; $result .= 'メッセージが送信できませんでした。後ほど再度お試し下さい。'; $result .= '</div>'; echo $result; die(); ?>
サーバー側のPHPの文字コード設定は
mbstring.language Japanese
mbstring.internal_encoding UTF-8
mbstring.http_input pass
mbstring.http_output pass
mbstring.encoding_translation Off
mbstring.detect_order auto
mbstring.substitute_character none
です。
調べて色々試しましたがお手上げです。どうかご教授お願いします。
回答2件
あなたの回答
tips
プレビュー