What charset should I use when I send an email through PHP?


Use this charset :

   $mailHeader2 .= "Mime-Version: 1.0 \r\n";
   $mailHeader2 .= "Content-Type: text/html; charset=utf-8"; 
asked by Ing. Marquez Adam 29.01.2016 в 21:00

2 answers


Imagining that your problem is related to characters with accents and eñes, it is very likely that you should use the UTF-8 charset.

Using the information in this answer , this would be the code of your header:

$mailHeader2 .= "Content-Type: text/html; charset=utf-8";

And if the content of your email does not have any HTML, then you can use this header:

$mailHeader2 .= "Content-Type: text/plain;charset=utf-8";

Also, make sure that the charset of your PHP file is the same as the one you are placing in the header. That is, if you are going to send the email in UTF-8, your PHP file must also be written in UTF-8.

answered by 29.01.2016 / 21:05

charset=utf-8 , since it contains all the characters of the Spanish language.

answered by 31.01.2016 в 08:56