Skip to content

Instantly share code, notes, and snippets.

@fmagrosoto
Last active December 15, 2015 07:39
Show Gist options
  • Save fmagrosoto/5225345 to your computer and use it in GitHub Desktop.
Save fmagrosoto/5225345 to your computer and use it in GitHub Desktop.
Script sencillo para mandar correos en PHP, usando MAIL como función principal.
<?php
/**
* SCRIPT PARA ENVIAR CORREOS DESDE PHP
*
* Script sencillo para enviar datos de un formulario
* por correo mediante MAIL de PHP
*
* @author: Fernando Magrosoto V
* @copyright: Febrero 2000
*/
if(isset($_POST['submit'])){
$nombre = htmlspecialchars($_POST['nombre']);
$correo = htmlspecialchars($_POST['correo']);
$telefono = htmlspecialchars($_POST['telefono']);
$ciudad = htmlspecialchars($_POST['ciudad']);
$comentarios = htmlspecialchars($_POST['comentarios']);
$subject = "Formulario de contacto de PATY BUENO";
$para = "tucuentadecorreo@valido.ext";
$de = "direccion@remitente.ext";
$mensaje = "Alguien ha enviado un formulario.";
$mensaje .= "\n";
$mensaje .= "Aquí están los datos: ";
$mensaje .= "\n\n";
$mensaje .= "Nombre: ".$nombre."\n";
$mensaje .= "Correo: ".$correo."\n";
$mensaje .= "Teléfono: ".$telefono."\n";
$mensaje .= "Ciudad: ".$ciudad."\n";
$mensaje .= "Comentarios: ".$comentarios."\n\n";
$mensaje .= "----------------------\n";
$mensaje .= "Guarde este correo para futuras revisiones.";
if(mail($para, $subject,$mensaje,"From: $de")){
header("Location: contacto_confirm.html");
exit();
}
// fin
} else {
echo "No se ha enviado ningún form";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment