Answer the question
In order to leave comments, you need to log in
Why is the sender displayed as "squiggles" in a letter from a form?
Good afternoon!
There is the following form:
<?php
$usermail = $_POST['email'];
$sendto = $usermail;
$content = nl2br($_POST['msg']);
// Формирование заголовка письма
$subject = "Прайс-лист ООО \"Фирма АИВ\"";
$headers .= "From: Фирма АИВ\r\n";
$headers .= "Reply-To: ". $usermail . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html;charset=utf-8 \r\n";
// Формирование тела письма
$msg = "<html><body style='font-family:Arial,sans-serif;'>";
$msg .= "<p>Текст письма</p>\r\n";
$msg .= "</body></html>";
// отправка сообщения
if(@mail($sendto, $subject, $msg, $headers)) {
echo "true";
} else {
echo "false";
}
?>
Answer the question
In order to leave comments, you need to log in
In the yard 2014, use already normal libraries for sending mail, for example swiftmailer.org
But if you really like bicycles, then I can offer my century ago:
<?php
class MyMail
{
public static function send($to, $fromMail, $fromName, $subject, $message)
{
$subject = '=?utf-8?B?'.base64_encode($subject).'?=';
$header = "From: \"$fromName\" <$fromMail>\n";
$header .= "Subject: $subject\n";
$header .= "Mime-Version: 1.0\n";
$header .= "Content-type: text/html; charset=\"utf-8\"\n";
$body = "$message";
@mail( $to, $subject, $body, $header, " -f $fromMail" );
}
}
$headers .= 'From: =?utf-8?B?'.base64_encode('Фирма АИВ')."?=\r\n";
The problem is with encodings, as the answers suggest.
Google advises to search here:
php.net/manual/ru/ref.mbstring.php (many letters)
habrahabr.ru/post/158895 (many letters on the case and with examples)
www.itdumka.com.ua/index.php?cmd= shownode&node=23 (very short)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question