Answer the question
In order to leave comments, you need to log in
How to send email with PHP script in UTF-8?
The site has a feedback form, but the letters come in unreadable encoding. What to add so that everything still goes in UTF-8?
<?
if (array_key_exists('messageFE', $_POST)) {
mail ("[email protected]",
"Пришел вопрос с ".$_SERVER['HTTP_REFERER'],
"Имя: ".$_POST['nameFE']."\nEmail: ".$_POST['phoneFE']."\nВопрос: ".$_POST['messageFE']);
echo $_POST['nameFF'];
}
?>
Answer the question
In order to leave comments, you need to log in
The encoding is specified in the headers, there is a great example of sending emails.
for example here:
<?php
function mail_utf8($to, $from_user, $from_email,
$subject = '(No subject)', $message = '')
{
$from_user = "=?UTF-8?B?".base64_encode($from_user)."?=";
$subject = "=?UTF-8?B?".base64_encode($subject)."?=";
$headers = "From: $from_user <$from_email>\r\n".
"MIME-Version: 1.0" . "\r\n" .
"Content-type: text/html; charset=UTF-8" . "\r\n";
return mail($to, $subject, $message, $headers);
}
?>
It is best to use some library like this for example, and sending for you will be a quick and elementary thing.
Check .htaccess AddDefaultCharset UTF-8
And the pages must also be in UTF-8
and the actual header of the letter must contain charset=UTF-8
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question