Skip to content

Instantly share code, notes, and snippets.

@ricardodantas
Created January 31, 2014 13:43
Show Gist options
  • Save ricardodantas/8732274 to your computer and use it in GitHub Desktop.
Save ricardodantas/8732274 to your computer and use it in GitHub Desktop.
Função para codificar email para UTF8 no envio de emails pela função "mail()" do PHP.
function utf8mail($to,$s,$body,$from_name="x",$from_a = "[email protected]", $reply="[email protected]")
{
$s= "=?utf-8?b?".base64_encode($s)."?=";
$headers = "MIME-Version: 1.0\r\n";
$headers.= "From: =?utf-8?b?".base64_encode($from_name)."?= <".$from_a.">\r\n";
$headers.= "Content-Type: text/plain;charset=utf-8\r\n";
$headers.= "Reply-To: $reply\r\n";
$headers.= "X-Mailer: PHP/" . phpversion();
mail($to, $s, $body, $headers);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment