Created
July 10, 2012 02:29
-
-
Save ealbinu/3080619 to your computer and use it in GitHub Desktop.
Correo con PHP utilizando mail() codificado en UTF-8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$correo_destinatario = ""; | |
$nombre_remitente = ""; | |
$correo_remitente = ""; | |
$asunto = ""; | |
$mensaje = ""; | |
$headers = "From: ".$nombre_remitente."\r\n"."Reply-To: ".$correo_remitente."\r\n"."X-Mailer: PHP/".phpversion(); | |
function mailutf8($correo_destinatario, $asunto = "(Sin Asunto)", $mensaje="", $header=""){ | |
$header_on = "MIME-Version: 1.0"."\r\n"."Content-type: text/html; charset=UTF-8"."\r\n"; | |
if(mail($correo_destinatario, "=?UTF-8?B?".base64_encode($asunto)."?=", $mensaje, $header_on.$header)){ | |
echo "Mensaje enviado"; | |
} else { | |
echo "Error en el envío"; | |
} | |
} | |
mailutf8($correo_destinatario, $asunto , $mensaje, $headers); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
¡Hola! Pasaba por aquí para dejarte una versión mejorada (aunque yo, personalmente, prefiero usar PHPMailer):
https://gist.github.com/ojgarciab/32d085858d0a469f6842ee78b82a4666
¡Un saludo!