Skip to content

Instantly share code, notes, and snippets.

@ealbinu
Created July 10, 2012 02:29
Show Gist options
  • Save ealbinu/3080619 to your computer and use it in GitHub Desktop.
Save ealbinu/3080619 to your computer and use it in GitHub Desktop.
Correo con PHP utilizando mail() codificado en UTF-8
$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);
@ojgarciab
Copy link

¡Hola! Pasaba por aquí para dejarte una versión mejorada (aunque yo, personalmente, prefiero usar PHPMailer):
https://gist.github.com/ojgarciab/32d085858d0a469f6842ee78b82a4666
¡Un saludo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment