A
A
Anton Shcherbinin2019-04-04 14:23:14
Email
Anton Shcherbinin, 2019-04-04 14:23:14

Unrecognizable encoding of mail coming from the site?

Friends, good afternoon!
All pages of the site (under Linux hosting) are in UTF-8, which, of course, is spelled out (the beginning of the HTML:

<!DOCTYPE html>
<html lang="ru-RU" dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
.......

Next is php:
<?php

  $errors = array();

  if (!isset($_POST['name'])) {
    $errors['name'] = 'Введите, пожалуйста, своё имя.';
  }

  if (!isset($_POST['email']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
    $errors['email'] = 'Введите, пожалуйста, адрес своей электронной почты';
  }

  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">&times;</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;
  $to = '[email protected]';  
  $subject = 'Contact Form : Anton';

  $body = "From: $name\n E-Mail: $email\n Message:\n $message";

  $headers = "From: ".$from;


  $result = '';
  if (mail ($to, $subject, $body, $headers)) {
    $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">&times;</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">&times;</span></button>';
  $result .= 'Something bad happend during sending this message. Please try again later';
  $result .= '</div>';

  echo $result;</b>

However, no matter what I do, bugs come, which even the transcoder only partially parses (in particular, it does not convert large letters, and not all lowercase letters) ...
What could be the reason and how to fix it?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Valentin, 2019-04-04
@romanko_vn

Try adding this

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

A
Anton Shcherbinin, 2019-04-04
@sfumato

Thank you, Valentin. Did not help.
I tried to change the e-mail address , so on yandex.ru it turns out, for some reason, letters do not come at all ...!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question