|
|
<?php
|
|
|
|
|
|
$deportista = htmlentities($_POST["deportista"]);
|
|
|
$entrenador = htmlentities($_POST["entrenador"]);
|
|
|
$nombre = htmlentities($_POST["nombre"]);
|
|
|
|
|
|
$returnValue = array();
|
|
|
|
|
|
if(empty($nombre) || empty($deportista) || empty($entrenador))
|
|
|
{
|
|
|
$returnValue["status"] = "error";
|
|
|
$returnValue["message"] = "Hay que rellenar todos los campos";
|
|
|
echo json_encode($returnValue);
|
|
|
return;
|
|
|
}
|
|
|
// Función que podría ser interesante
|
|
|
// Si cualquier línea es más larga de 70 caracteres, se debería usar wordwrap()
|
|
|
// $mensaje = wordwrap($mensaje, 70, "\r\n");
|
|
|
|
|
|
// Mensaje para el entrenador.
|
|
|
|
|
|
$para = $entrenador;
|
|
|
$asunto = "Solicitud de entrenador";
|
|
|
$mensaje = "Buenos días,\n\nMe gustaría obtener más información acerca de los servicios de entrenamiento personal.\n\n Gracias";
|
|
|
$cabecera = 'From: '.$nombre.' <'.$deportista.'>' . PHP_EOL .
|
|
|
'Reply-To: '.$nombre.' <'.$deportista.'>' . PHP_EOL .
|
|
|
'X-Mailer: PHP/' . phpversion();
|
|
|
|
|
|
//print("para ".$para.", asunto: ".$asunto.", mensaje: ".$mensaje.", cabecera: ".$cabecera);
|
|
|
//return;
|
|
|
|
|
|
if (mail($para, $asunto, $mensaje, $cabecera)) {
|
|
|
$returnValue["status"] = "correcto";
|
|
|
$returnValue["message"] = "mensaje enviado con exito";
|
|
|
echo json_encode($returnValue);
|
|
|
return;
|
|
|
} else {
|
|
|
$returnValue["status"] = "error";
|
|
|
$returnValue["message"] = "fallo en envio de mensaje";
|
|
|
echo json_encode($returnValue);
|
|
|
return;
|
|
|
}
|
|
|
?>
|