D
D
Dmitry2017-05-16 17:37:13
PHP
Dmitry, 2017-05-16 17:37:13

Mail() wrong encoding?

Hello, I send the form to the mail with the following code

if (isset($_POST['send1'])) {

      $body = "Форма обратной связи \r\n\r\nИмя: ".$_POST['name']."\r\nТелефон: ".$_POST['phone'];

      $subject = "Форма обратной связи CellGSM";

      $adress = '[email protected]';

      mail($adress, $subject, $body);

            echo "<center><h1>Мы с вами свяжемся :)</h1></center>";

    
    }

But the Cyrillic alphabet comes to the mail in this form:
Phone: ���ñ

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry, 2017-05-16
@slo_nik

Good evening.
Add a header that will specify the desired encoding.

$headers .= "Content-type: text/html; charset=\"utf-8\"\n";

B
Boris Korobkov, 2017-05-16
@BorisKorobkov

Because it is necessary to comply with the RFC www.faqs.org/rfcs/rfc2047.html
In order not to reinvent the wheel, use ready-made libraries. For example pear.php.net/package/Mail_Mime , https://github.com/PHPMailer/PHPMailer or similar

A
Alex Teterin, 2017-05-16
@errogaht

You need to use libraries to send emails, then there will be no problems.
For example PHPMailer or swiftmailer.org

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question