Send unicode emoji with PHPMailer

前端 未结 2 1302
遇见更好的自我
遇见更好的自我 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';
    

提交回复
热议问题