<?php

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

$adminemail = "contacto@visionarios.org, leads3@leadmeagency.com";
// $clientemail = $_POST['Correo'];
// $cco = "andres@leadmeagency.com";

// 
	$nombre = limpiar($_POST['Nombre']);
	$mail = $_POST['Correo'];
	
    $mail_caract = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/";
	
	if($nombre=="" || $mail=="")
	{
		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 \n";
			$headers = "MIME-Version: 1.0\r\n" ;
			$headers .= "Content-Type: text/html; charset=utf-8\n";
			$headers .= "From: ".$mail."\nReply-To:".$mail."\n";

			$headersClient .= "X-Sender: ".$adminemail."\n";
			$headersClient .= "X-Priority: 1\n";
			$headersClient .='x-mailer: php/' . phpversion() . "\r\n"; 
			$headersClient .= "X-Mailer: PHP \n";
			$headersClient = "MIME-Version: 1.0\r\n" ;
			$headersClient .= "Content-Type: text/html; charset=utf-8\n";
			$headersClient .= "From: ".$adminemail."\nReply-To:".$adminemail."\n";

	
			$tema= "Nuevo Suscriptor";
	
			$mensaje="
			<div style='padding: 10px 20px;background: #444;position: relative; text-align: center;'>
				<p style='color: #fff;font-size: 30px;margin: 0px;'>Registro</p>
			</div>
			<table width='100%' border='0' align='center' style='background-color:#eee; width:100%;padding: 20px;'>
			  <tbody align='center'>
				<tr>
				  	<td width='50%' align='right'>
				  		<span style='color: #000;font-size:17px;margin-right: 15px;'>Nombre: </span> 
				  	</td>
                    <td width='50%' align='left'>
				  		<span style='color: #000;font-size:17px;'>".$nombre."</span>
				  	</td>
				</tr>
                <tr>
					<td width='50%' align='right'>
						<span style='color: #000;font-size:17px;margin-right: 15px;'>Correo electrónico: </span>
					</td>
                    <td width='50%' align='left'>
						<span style='color: #000;font-size:17px;'>".$mail."</span>
					</td>
				</tr>
			  </tbody>
			</table>
            <table width='100%' border='0' align='center' style='background-color:#eee; width:100%;padding: 0 0 0 20px;'>
			  <tbody align='center'>
                <tr>
                    <td width='100%' align='center'>
                        <hr />
                        <p><img class='' src='http://visionarios2030.com/archivos/logos/Visionarios2030-Logo_Negro.svg' alt='' width='230' height='70' /></p>
                        <hr />
                    </td>
                </tr>
			  </tbody>
			</table>
			";
			mail($adminemail,$tema,$mensaje,$headers);
			// mail($cco,$tema,$mensaje,$headers);
			// mail($clientemail,$temaclient,$msgClientLarge,$headersClient);
				 echo 0;
}
?>