PHP gets email contact addresses such as 163, gmail, 126, etc.

WBOY
Release: 2016-07-29 08:40:56
Original
2027 people have browsed it

I found some on the Internet, most of them have expired, so I reorganized them; I specially released the code of 126, 163 is easier to grab; 126 is a bit abnormal and has one more jump, which is more troublesome

Copy Code The code is as follows:


/**
* @file class.126http.php
* Get the 126 email address list
* @author jvones http://www.jvones.com/blog
* @date 2009-09-26
**/
class http126
{
private function login($username, $password)
{
//First step: initial login
$cookies = array();
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, "https://reg.163.com/logins.jsp?type=1&product=mail126&url=http: //entry.mail.126.com/cgi/ntesdoor?hid%3D10010102%26lightweight%3D1%26verifycookie%3D1%26language%3D0%26style%3D-1");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=".$username."@126.com&password=".$password);
curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR);
curl_setopt($ch,CURLOPT_HEADER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, TIMEOUT);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$str = curl_exec($ch);
//file_put_contents('./126result.txt', $str);
curl_close ($ch);
//Get the redirect_url jump address, which can be viewed from 126result.txt, and match the address in the $str return stream through regular expressions
preg_match("/replace("(.*?)");/ ", $str, $mtitle);
$_url1 = $mtitle[1];
//file_put_contents('./126resulturl.txt', $redirect_url);
//Step 2: Jump to the top again$ _url1
$ch = curl_init($_url1);
curl_setopt($ch, CURLOPT_TIMEOUT, TIMEOUT);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_COOKIEFILE,COOKIEJAR);
curl_ setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR);
curl_setopt($ch,CURLOPT_HEADER,1);
$str2 = curl_exec($ch);
curl_close($ch);
if (strpos($contents, "Safe Exit") !== false )
{
return 0;
}
return 1;
}
/**
* Get email address book-address
* @param $user
* @param $password
* @param $result
* @return array
*/
public function getAddressList($username, $password)
{
if (!$this->login($username , $password))
{
return 0;
}
$header = $this->_getheader($username);
if (!$header['sid'])
{
return 0;
}
/ /Test to find out sid (very important) and host
//file_put_contents('./host.txt', $header['host']);
//file_put_contents('./sid.txt', $header[' sid']);
//Start entering simulated crawling
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://".$header['host']."/a/s? sid=".$header['sid']."&func=global:sequential");
curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIEJAR);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/xml "));
$str = "pab :searchContactsFNtrueuser:getSignaturespab:getAllGroups";
curl_setopt($ch, Curlopt_post, 1);
CURL_SETOPT ($ CH, CURLOPT_POSTFIELDS, $ Str); exec ($ ch);
$ contents = ob_get_contents ();
ob_end_clean ();
curl_close($ch);
//get mail list from the page information username && emailaddress
preg_match_all("/(.*) /Umsi",$contents,$mails);
preg_match_all("/(.*)/Umsi",$contents,$names);
$users = array();
foreach($names[1] as $k=>$user)
{
//$user = iconv($user,'utf-8','gb2312');
$users[ $mails[1][$k]] = $user;
}
if (!$users)
{
return 'There are no contacts in your mailbox yet';
}
return $users;
}
/**
* Get Header info
*/
private function _getheader($username)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://entry.mail.126.com/cgi/ntesdoor?hid=10010102&lightweight=1&verifycookie=1&language=0&style=-1&username=".$username."@126.com");
curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIEJAR); //当前使用的cookie
curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR); //服务器返回的新cookie
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
$c
preg_match_all('/Location:s*(.*?)rn/i',$content,$regs);
$refer = $regs[1][0];
preg_match_all('/http://(.*?)//i',$refer,$regs);
$host = $regs[1][0];
preg_match_all("/sid=(.*)/i",$refer,$regs);
$sid = $regs[1][0];
curl_close($ch);
return array('sid'=>$sid,'refer'=>$refer,'host'=>$host);
}
}
?>


 PHP获取163、gmail、126等邮箱联系人地址 

以上就介绍了 PHP获取163、gmail、126等邮箱联系人地址,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!