www.anhida.es/email
Cita:
<form action="envio.php" method="POST" id="fo3">
<!--[if IE]><label>Nombre:</label><![endif]-->
<input required type="text" type="text" title="Nombre: Julio Verne" name="nombre" style="width:100%;" placeholder="Nombre: Julio Verne" maxlength="30" />
<!--[if IE]><label>Email:</label><![endif]-->
<div class="div"><input required type="email" name="email" title="Email: [email protected]" style="width:100%;" placeholder="Email: [email protected]" maxlength="40" pattern="[a-zA-Z0-9.+_-]{2,25}@[a-zA-Z0-9.-]{2,15}\.[a-zA-Z0-9.-]{2,9}" /></div>
<!--[if IE]><label>Asunto:</label><![endif]-->
<input required type="text" title="Asunto: Titulo" name="asunto" style="width:100%;" type="text" placeholder="Asunto: Titulo" maxlength="30" />
<!--[if IE]><label>Mensaje:</label><![endif]-->
<textarea required style="width:100%;" rows="6" title="Mensaje: Texto de prueba" name="mensaje" placeholder="Mensaje: Texto de prueba" maxlength="" ></textarea>
<select name="para" style="width:100%;">
<option value="[email protected]">Anhida Vigo</option>
<option value="[email protected]">Anhida FerrolTerra</option>
<option value="[email protected]">Anhida Coruña</option>
<option value="[email protected]">Webmaster</option>
</select>
<br/>
<input name="enviar" type="submit" value="Enviar" style="width:50%;" /><input name="reset" type="reset" value="Borrar" style="width:50%;" />
</form>
<!--[if IE]><label>Nombre:</label><![endif]-->
<input required type="text" type="text" title="Nombre: Julio Verne" name="nombre" style="width:100%;" placeholder="Nombre: Julio Verne" maxlength="30" />
<!--[if IE]><label>Email:</label><![endif]-->
<div class="div"><input required type="email" name="email" title="Email: [email protected]" style="width:100%;" placeholder="Email: [email protected]" maxlength="40" pattern="[a-zA-Z0-9.+_-]{2,25}@[a-zA-Z0-9.-]{2,15}\.[a-zA-Z0-9.-]{2,9}" /></div>
<!--[if IE]><label>Asunto:</label><![endif]-->
<input required type="text" title="Asunto: Titulo" name="asunto" style="width:100%;" type="text" placeholder="Asunto: Titulo" maxlength="30" />
<!--[if IE]><label>Mensaje:</label><![endif]-->
<textarea required style="width:100%;" rows="6" title="Mensaje: Texto de prueba" name="mensaje" placeholder="Mensaje: Texto de prueba" maxlength="" ></textarea>
<select name="para" style="width:100%;">
<option value="[email protected]">Anhida Vigo</option>
<option value="[email protected]">Anhida FerrolTerra</option>
<option value="[email protected]">Anhida Coruña</option>
<option value="[email protected]">Webmaster</option>
</select>
<br/>
<input name="enviar" type="submit" value="Enviar" style="width:50%;" /><input name="reset" type="reset" value="Borrar" style="width:50%;" />
</form>
Cita:
<?php
//variable de validacion
$valida = true;
if (empty($_POST['nombre'])) {
echo "<b>No se especifico nombre</b><br/>";
$valida = false;
}
if (empty($_POST['email'])) {
echo "<b>No se especifico E - mail</b><br/>";
$valida = false;
}
if (empty($_POST['asunto'])) {
echo "<b>No se especifico asunto</b><br/>";
$valida = false;
}
if (empty($_POST['mensaje'])) {
echo "<b>Por favor, no envie un mensaje en blanco</b><br/>";
$valida = false;
}
// Validamos la direccion de correo electronico
if (!strchr($_POST['email'],"@") || !strchr($_POST['email'],"."))
{
echo "<b>No es un correo valido</b><br/>";
$valida = false;
}
// Si las comprobaciones son correctas
if ($valida == true)
{
// Creamos el header para el mensaje
// para:
$to = $_POST['para'];
// Asunto
$subject = $_POST['asunto'];
// Cabeceras del mail (Content-Type y demas info)
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=utf-8\n";
// El From: en la forma Nombre <[email protected]>, esto garantiza que
// el receptor vea solo el nombre de quien envia
$headers .= "From: ".$_POST['nombre']." <".$_POST['email'].">\n";
// Opcional: Resopnder a:
$headers .= "Reply-To: " . $_POST['email']."\n";
//Opcional X-Mailer
$headers .= "X-Mailer: PHP/" . phpversion();
// Cuerpo del email
$message = $_POST['mensaje'];
if(mail($to, $subject, $message,$headers))
{
echo "<p>Email enviado correctamente.</p>";
}else{
echo "Corrija el formulario.<br/>en unos segundos vera el formulario";
}
}
?>
//variable de validacion
$valida = true;
if (empty($_POST['nombre'])) {
echo "<b>No se especifico nombre</b><br/>";
$valida = false;
}
if (empty($_POST['email'])) {
echo "<b>No se especifico E - mail</b><br/>";
$valida = false;
}
if (empty($_POST['asunto'])) {
echo "<b>No se especifico asunto</b><br/>";
$valida = false;
}
if (empty($_POST['mensaje'])) {
echo "<b>Por favor, no envie un mensaje en blanco</b><br/>";
$valida = false;
}
// Validamos la direccion de correo electronico
if (!strchr($_POST['email'],"@") || !strchr($_POST['email'],"."))
{
echo "<b>No es un correo valido</b><br/>";
$valida = false;
}
// Si las comprobaciones son correctas
if ($valida == true)
{
// Creamos el header para el mensaje
// para:
$to = $_POST['para'];
// Asunto
$subject = $_POST['asunto'];
// Cabeceras del mail (Content-Type y demas info)
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=utf-8\n";
// El From: en la forma Nombre <[email protected]>, esto garantiza que
// el receptor vea solo el nombre de quien envia
$headers .= "From: ".$_POST['nombre']." <".$_POST['email'].">\n";
// Opcional: Resopnder a:
$headers .= "Reply-To: " . $_POST['email']."\n";
//Opcional X-Mailer
$headers .= "X-Mailer: PHP/" . phpversion();
// Cuerpo del email
$message = $_POST['mensaje'];
if(mail($to, $subject, $message,$headers))
{
echo "<p>Email enviado correctamente.</p>";
}else{
echo "Corrija el formulario.<br/>en unos segundos vera el formulario";
}
}
?>