<?php

function limpiar($string ){
 $string = preg_replace('(\<(/?[^\>]+)\>)', '', $string);
 return $string;
}


$adminemail = "itprogrammer@strave.com";
$ccp1 = "";
$cco = "";
 		
		
	$nombre = limpiar($_POST['nombre']);
	$tel = limpiar($_POST['tel']);
	$mail = $_POST['mail'];
	$mje	=	limpiar($_POST['msj']);


/*echo $nombre;	
echo $mail;
echo $tel;
echo $mje;*/
	
	
	
	
	
	
$mail_caract = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/";
	
						
	

	if($nombre=="" || $tel=="" || $mail=="" || $mje=="")
	{
		echo 1;
	} 
	elseif(!preg_match($mail_caract, $mail)){
		
		
		echo 2;
		
	}else{
		
		
	
									$headers .= "X-Sender: ".$adminemail."\n";

									$headers .= "X-Priority: 1\n";

									$headers .='x-mailer: php/' . phpversion() . "\r\n"; 

									$headers .= "X-Mailer: PHP - SchoolStore\n";

									$headers = "MIME-Version: 1.0\r\n" ;

									  $headers .= "Content-Type: text/html; charset=utf-8\n"; // Mime type

									$headers .= "From: ".$mail."\nReply-To:".$mail."\n";

							
							
									$tema= "Te han contactado desde SchoolStore" ;
							
									$mensaje="
									<table width='50%' border='0' align='center' >
									  <tbody>						
										
										<tr>
										  <td style='font-weight:600; color: #000; text-align: left; font-size:14px;'>Nombre: <span style='color: #000'>".$nombre."</span></td>
										</tr>
										<tr>
										  <td style='font-weight:600; color: #000; text-align: left; font-size:14px;'>Teléfono: <span style='color: #000'>".$tel."</span></td>
										</tr>
										<tr>
											<td style='font-weight:600; color: #000; text-align: left; font-size:14px;'>E-mail: <span style='color: #000'>".$mail."</span></td>
										</tr>
										<tr>
										  <td style='font-weight:600; color: #000; text-align: left; font-size:14px;'>Mensaje: <span style='color: #000'>".$mje."</span></td>
										</tr>
                                       
                                        
									  </tbody>
									</table>
									";
									mail($adminemail,$tema,$mensaje,$headers); 
									mail($ccp1,$tema,$mensaje,$headers);
									mail($ccp2,$tema,$mensaje,$headers);
									mail($cco,$tema,$mensaje,$headers);
										 echo 0;



}




?>