M
M
MaksSmag2020-11-15 18:50:02
PHP
MaksSmag, 2020-11-15 18:50:02

A message with Russian letters is not sent. How to fix?

I deployed a mail server on PostFix, I send a message with mail() in PHP, I noticed a strange feature - if there is at least one Russian letter in the message header, then mail.ru does not seem to see the message, not even in spam. And in the server logs it is written that the mail received the message without errors. Maybe you need to encode? (The Russian text of the message itself is displayed without problems)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2020-11-16
@MaksSmag


subject
The subject of the email being sent.
Caveat
The subject must comply with » RFC 2047.

https://www.php.net/manual/ru/function.mail.php
There is an example below in the comments:
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);
   }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question