简体   繁体   中英

PHP contact form: cyrillic letter not being sent if it is not short

I am making a contact form on my website and, trying to submit it, I get two outcomes:
1. I wrote email in english, and, no matter how long it is, it is sent perfectly fine.
2. I wrote it in russian. If it is shorter than about 10 symbols - I get the email and it is even correctly rendered. If it is longer than that - I just never get this email!

my html header includes:

  <meta charset="UTF-8" name="viewport" HTTP-EQUIV="Pragma">

my form:

  <form method="post" action="a.php">
    <input type="text" name="name">
    <input type="submit">
  </form>

my a.php:

<?php

$name = $_POST['name'];

$header = "From: Hi";
$header .= "Content-Type: text/plain; charset=utf-8";

$subject = "This is letter";
$email_to = "***my email***";
$message = "Name: $name."

mail($email_to, $subject, $message, $header);

?>

Please help, I don't have a clue on why is that and how to fix it.

$subject = '=?UTF-8?B?' . base64_encode($subject) . '?='; 

What base64_encode() does is best explained in PHP manual :

base64_encode() is designed to make binary data survive transport through transport layers that are not 8-bit clean, such as mail bodies.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM