Send unicode emoji with PHPMailer

前端 未结 2 1300
遇见更好的自我
遇见更好的自我 2021-01-05 20:07

I\'m trying to send unicode emoji trough PHPMailer (5.2) but the emails I sent are received with weird characters instead of emojis. I\'m currently sending HTML emails where

相关标签:
2条回答
  • 2021-01-05 20:54

    It turns out that PHPMailer uses charset=iso-8859-1 by default in HTML emails (in the email header you'll find Content-Type: text/html; charset=iso-8859-1 while you should use UTF-8: Content-Type: text/html; charset=UTF-8.

    You can set the charset in PHPMailer by doing:

    $mail = new PHPMailer();
    $mail->CharSet = 'UTF-8';
    
    0 讨论(0)
  • 2021-01-05 21:02

    I needed to use the slightly different:

    $mail = new PHPMailer();
    $mail->CharSet = 'utf-8';
    
    0 讨论(0)
提交回复
热议问题