Skip to content

Instantly share code, notes, and snippets.

@jcguarinpenaranda
Created April 29, 2016 00:57
Show Gist options
  • Save jcguarinpenaranda/8103dad31be5062fed641f82beb473f3 to your computer and use it in GitHub Desktop.
Save jcguarinpenaranda/8103dad31be5062fed641f82beb473f3 to your computer and use it in GitHub Desktop.
Enviar un email a una dirección de correo, cuando se haya enviado un formulario de contacto
<?php
if (isset($_POST['nombre']) && isset($_POST['correo']) && isset($_POST['asunto']) && isset($_POST['empresa']) && isset($_POST['mensaje'])) {
// Varios destinatarios
$correo= $_POST['correo'];
$nombre = html_entity_decode($_POST['nombre']);
$asunto = html_entity_decode($_POST['asunto']);
$mensajepost = html_entity_decode($_POST['mensaje']);
$empresa = html_entity_decode($_POST['empresa']);
$para = $correo;
// subject
$titulo = 'Gracias por contactarnos';
// message
$mensaje = '
<html>
<head>
<title>Contacto a PAGINA</title>
<meta charset="UTF-8">
</head>
<body>
<style>
p{
font-size:12px;
}
#content{
width: 50%;
margin: 20px auto;
}
h1{
font-size:20px;
}
.comment{
font-size:10px;
}
</style>
<div id="content">
<h1>¡Hola ' . $nombre . '!</h1>
<p>Gracias por contactarte con PAGINA, tu mensaje será leido y respondido cuanto ántes.</p>
<p>Estos son los datos enviados:</p>
<ul>
<li>Nombre:' . $nombre . '</li>
<li>Asunto:' . $asunto . '</li>
<li>Empresa:' . $empresa . '</li>
<li>Correo: ' . $correo . '</li>
</ul>
<h3>Mensaje enviado:</h3>
<p>'.$mensajepost.'</p>
</div>
</body>
</html>
';
$remitente = "from: PAGINA <noreply@pagina.com>\nMIME-Version: 1.0\nContent-Type: text/html; charset=UTF-8\nX-Mailer: WebMail";
// Mail it
mail("tu correo @ proveedor .com ", "Contacto desde PAGINA.COM", $mensaje, $remitente);
mail($para, $titulo, $mensaje, $remitente);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment