How do I send emails with Arabic content via PHP's mail function?

后端 未结 4 1697
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 13:11

I\'m having a challenge with sending emails with arabic content using PHP\'s mail function. Let\'s say I have this simple arabic string:

بريد

I\'ve tried sev

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-30 13:42

            $boundary = uniqid(rand(), true);
    
            $headers  = "From: $from\n";
            $headers .= "MIME-Version: 1.0\n";
            $headers .= "Content-Type: multipart/alternative; boundary = $boundary\n";
            $headers .= "This is a MIME encoded message.\n\n";
            $headers .= "--$boundary\n" .
                        "Content-Type: text/plain; charset=UTF-8 \n" .
                        "Content-Transfer-Encoding: base64\n\n";
            $headers .= chunk_split(base64_encode($plaintext));
            $headers .= "--$boundary\n" .
                        "Content-Type: text/html; charset=ISO-8859-1\n" .
                        "Content-Transfer-Encoding: base64\n\n";
            $headers .= chunk_split(base64_encode($msg));
            $headers .= "--$boundary--\n" .
    
    
            mail($address, $subject, '', $headers);
    

    This one works for me.

提交回复
热议问题