PHP and Russian Letters

前端 未结 3 1059
情话喂你
情话喂你 2021-01-20 15:40

What is happening with Russian letters when sending via PHP request to ... a mail, by e.g.? the \"hardcoded\" russians letters are displayed properly, but from the Form\'s t

相关标签:
3条回答
  • 2021-01-20 16:24

    As well as what Alix said about base64 in the RFC2047 encoded-word in your Subject line, you also need to tell the mailer to expect UTF-8-encoded text in the body of the mail, by adding headers:

    MIME-Version: 1.0
    Content-Type: text/plain;charset=utf-8
    

    otherwise it's up to the mailer to guess, probably wrongly.

    0 讨论(0)
  • 2021-01-20 16:29

    You need to base64_encode() your $subject, like this:

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

    Make sure you're also saving your .php file encoded as UTF-8 no BOM.


    This question might also interest you: Is this the correct way to send email with PHP?

    0 讨论(0)
  • 2021-01-20 16:33

    Check your encodings:

    1. HTML encoding (in the <meta http-equiv..> tag)
    2. PHP/HTML/template file encoding (what encoding your editor saves the file in)
    3. Database encoding (if applicable) (in what encoding the data in the tables is in)
    4. Database connection encoding (if applicable) (what encoding is used for database connections)

    and use UTF-8 for everything.

    0 讨论(0)
提交回复
热议问题