5){ $veces_error = true; } //Acceso if($pass == $pass_secundario && $veces_error == false){ //Registramos acceso correcto (opcional) $ch = curl_init("https://www.google.com/a/".$dominio); //$file_path = 'cookies.txt'; //curl_setopt($ch, CURLOPT_COOKIEJAR, $file_path); //curl_setopt($ch, CURLOPT_COOKIEFILE, $file_path); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_URL, "https://www.google.com/a/". $dominio ."/LoginAction2?service=mail"); curl_setopt($ch, CURLOPT_REFERER, "https://mail.google.com/a/". $dominio); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "ltmpl=default<mplcache=2&continue=https://mail.google.com/a/". $dominio ."&rm=false&Email=". $usuario ."&Passwd=". $password ."&rmShown=1&signIn=Sign+in&asts=&service=mail&hl=en&ss=1"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); $html = curl_exec ($ch); curl_close($ch); $pos = strpos($html, 'HREF'); $pos += 6; $pos_f = strpos($html, '&'); $direccion = $_SERVER['HTTP_REFERER']; $direccion_1 = substr($html, $pos, ($pos_f - $pos)); if(!empty($direccion_1)){ $direccion = $direccion_1; } header("Location: ". $direccion); }else{ if($veces_error == false){ //Sumamos 1 al control de errores (opcional) }else{ //Supero la cantidad de logueos fallidos permitidos (opcional) } } } entrar_correo_googleApps($_POST['pass']); } ?> Ingresar a Google Apps