Special characters php mail utf8

I have the following script:

<?php $subject = "Testmail — Special Characters"; $msg = "Hi there,\n\nthis isn't something easy.\n\nI haven't thought that it's that complicated!"; mail($to,$subject,$msg,$from."\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n"); ?> 

In the email:

Subject: Testmail ? Special Characters Testmail ? Special Characters

Body

 Hi there, this isn?t something easy. I haven?t thought that it?s that complicated! 

I tried a lot, but I have no more ideas. Can you help me? Have you ever got this job?

thanks!

+4
php email special-characters
source share
2 answers

Have you tried iconv_set_encoding ?

This should work:

 <?php iconv_set_encoding("internal_encoding", "UTF-8"); $subject = "Testmail — Special Characters"; $msg = "Hi there,\n\nthis isn't something easy.\n\nI haven't thought that it's that complicated!"; mail(utf8_decode($to), utf8_decode($subject), utf8_decode($msg), utf8_decode($from)."\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n");?> 
+12
source share

Use &rsquo; instead.

Example:

 The dog&rsquo;s bone. 

Make sure you change the content type from text / plain to text / html.

-one
source share

All Articles