0

I'm trying to add an emoticon(fire) in email subject. Below is the code I'm using:

$subject = "Test email \xF0\x9F\x94\xA5"; 
$charset = "UTF-8";
$subject = sprintf('=?%s?Q?%s?=', $charset, quoted_printable_encode($subject));
// send email....

This is adding a fire emoticon to the email subject successfully. But when I try to get the subject from database like:

$subject = $themeArray['templateSubject']; // Test email \xF0\x9F\x94\xA5 
$charset = "UTF-8";
$subject = sprintf('=?%s?Q?%s?=', $charset, quoted_printable_encode($subject));
// send email....

This is not converting the characters to emoticon. Instead I'm getting the subject in email as Test email \xF0\x9F\x94\xA5

Why its not converting when I get subject from database?

Can anyone help me to fix this? Thanks in advance.

Jenz
  • 8,280
  • 7
  • 44
  • 77
  • There is more to encoding a subject line than just that. Show the raw string bfore you encode it, and the *encoded* output of that function, not just the result of decoding it afterwards. [This CyberChef config](https://gchq.github.io/CyberChef/#recipe=From_Hex('Auto')To_Quoted_Printable()&input=XHhGMFx4OUZceDk0XHhBNQ) shows what should be happening with that string. Alternatively, use PHPMailer (that you tagged this question with), which deals with all this stuff so you don't have to. – Synchro Feb 11 '21 at 15:57
  • B and Q are different things. Which one you should use depends on your content. – Synchro Feb 11 '21 at 16:05

0 Answers0