L
L
LoveCode &Coffe2018-08-02 00:01:39
Email
LoveCode &Coffe, 2018-08-02 00:01:39

Why don't letters come in Russian (in Cyrillic) but only in English (Latin)?

There is a form on the site name, email and text. The form works on ajax

$("#form").submit(function() {
    $.ajax({
      type: "POST",
      url: "assets/app/mail.php",
      data: $(this).serialize()
    }).done(function() {
      $(this).find("input").val("");
      alert("Спасибо за заявку! Скоро мы с вами свяжемся.");
      $("#form").trigger("reset");
    });
    return false;
  });

here is the handler code
<?php

$recepient = "My_email";
$sitename = "my_site";

$name = trim($_POST["name"]);
$email = trim($_POST["email"]);
$text = trim($_POST["text"]);
$message = "Имя: $name \nЕmail: $email \nТекст: $text";

$pagetitle = "Письмо от клиента \"$sitename\"";
mail($recepient, $pagetitle, $message, "Content-type: text/plain; charset=\"utf-8\"\n From: $recepient");

Letters come if the login is in Latin and the text is in Latin. They do not come in Cyrillic

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2018-08-02
@Rsa97

1. In the headers of the letter, including the Subject (which for some reason you have called $pagetitle), only characters from ASCII-128 are allowed. All others, including Russian letters, must be encoded according to RFC2047 .
2. The From header must contain the real address of the sender and, optionally, his name according to RFC2822
3. Headers must be separated by \r\n (CR LF). There must be no spaces between this combination and the start of the next heading.
Any non-compliance with the standard either leads to an error in the delivery of the letter, or dramatically increases the likelihood of it falling into spam.

S
Stalker_RED, 2018-08-02
@Stalker_RED

Yeah, the devil will break his leg in this documentation). Why then...
telepaths are on vacation, it's hard to say why without seeing all your settings.
You have a choice: read the documentation more carefully and set everything up yourself (and there is a lot of complexity) or use some kind of wrapper over all this madness, which will try to do everything automatically .
I recommend PHPMailer .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question