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 I just echo
a string containing some utf-8 emoji and inspecting the email source the string seems to be printed correctly. For example:
echo "😁";
produces:
=F0=9F=98=81
in the email source code (which should be OK).
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';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With