-1

ウェブサイトにphpで作成したお問い合わせフォームがあります。問題は、英語の文字を完全に送信できるが、ロシア語の文字をサポートしていないことです。エンコーディングを変更する必要があるのですが、どうすればよいですか?

コードは次のとおりです。

<div id="center">
    <p class="please">Please contact us using this form.</p>
    <div id="formbox">
        <?
            if (isset ($_POST['message'])) {
            $name = @ trim ($_POST['name']);
            $contact = @ trim ($_POST['contact']);
            $message = @ trim ($_POST['message']);
            if (! $name or ! $contact or ! $message) echo ('<p style="color: red">You should fill in all the blanks.</p>');
            else { mail ("support@myemail.com",
                  "Message from Giftosite (Sender: $name)",
                  "$message \n\n Reply to: \n $contact");
                  echo ('<p style="color: green">Message has been sent, thank you!</p>');
                  $_POST['name'] = $_POST['contact'] = $_POST['message'] = '';
            }
            }
            ?>
            <form method="POST" class="form">
            <p class="formcontent">Your name:</p>
            <input name="name" value="<?=@$_POST['name'];?>">
            <p class="formcontent">Your e-mail address:</p>
            <input name="contact" value="<?=@$_POST['contact'];?>">
            <p class="formcontent">Message:</p>
            <textarea name="message" rows="6" cols="36"><?=@$_POST['message'];?></textarea>
            <p><input type="submit" value=" Send "></p>
            </form>
    </div>
</div>
4

2 に答える 2

3

メールにヘッダーを設定する

$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
           'Content-type: text/html; charset=UTF-8;' . "\r\n" .
           'Reply-To: webmaster@example.com' . "\r\n" .
           'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

したがって、これの代わりにコードで

mail ("support@myemail.com", $message from Giftosite (Sender: $name)", "$message \n\n Reply to: \n $contact");

あなたが持っているでしょう

$headers = 'From: webmaster@example.com' . "\r\n" .
           'Content-type: text/html; charset=UTF-8;' . "\r\n" .
           'Reply-To: webmaster@example.com' . "\r\n" .
           'X-Mailer: PHP/' . phpversion();
mail ("support@myemail.com", $message from Giftosite (Sender: $name)", "$message \n\n Reply to: \n $contact", $headers);
于 2012-06-22T07:09:24.140 に答える
0

Unicode文字を送信する前に、電子メールのヘッダーを設定する必要があります。これを試してください

$header_ = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=UTF-8' . "\r\n";
mail ("support@myemail.com",
                  "Message from Giftosite (Sender: $name)",
                  "$message \n\n Reply to: \n $contact", $header_);
于 2012-06-22T07:13:10.830 に答える