Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
- <?php
- $user = "ZABOEBATEJLb@mail.ru";
- $pass = "killer";
- $server = "pop.mail.ru";
- function from_detector ($text) {
- $pattern_from = "/(?<=From:\s).*/";
- preg_match($pattern_from, $text, $from);
- return $from[0];
- }
- function subject_detector($text) {
- $pattern_subject = "/(?<=Subject:\s).*/";
- preg_match($pattern_subject, $text, $subject);
- return $subject[0];
- }
- function decode_mime($text) {
- $string = $text;
- preg_match_all("#\=\?(.*)\?B\?#",$string,$val);
- $encoding = strtoupper($val[1][0]);
- if(($pos = strpos($string,"=?")) === false) return $string;
- while(!($pos === false)) {
- $newresult .= substr($string,0,$pos);
- $string = substr($string,$pos+2,strlen($string));
- $intpos = strpos($string,"?");
- $charset = substr($string,0,$intpos);
- $enctype = strtolower(substr($string,$intpos+1,1));
- $string = substr($string,$intpos+3,strlen($string));
- $endpos = strpos($string,"?=");
- $mystring = substr($string,0,$endpos);
- $string = substr($string,$endpos+2,strlen($string));
- if($enctype == "q") {
- $mystring = quoted_printable_decode(ereg_replace("_"," ",$mystring));
- }
- else if ($enctype == "b") {
- $mystring = base64_decode($mystring);
- }
- $newresult .= $mystring;
- $pos = strpos($string,"=?");
- }
- $result = $newresult.$string;
- if(preg_replace("/koi8/i", $result)) $result = convert_cyr_string($result, "k", "w");
- else if(!preg_replace("/windows-1251/i", $result)) $result = iconv($encoding,"WINDOWS-1251",$result);
- return $result;
- }
- function read_socket($socket){
- $data="";
- while (!feof($socket)) {
- $buffer = fgets($socket, 512);
- if ($buffer == false) {
- break;
- }
- $data .= "$buffer\r\n";
- }
- return $data;
- }
- $socket = fsockopen("pop.mail.ru", 110, $errno, $errstr, 30);
- stream_set_timeout($socket, 2);
- if (!$socket) {
- die($errstr. "($errno)<br />\n");
- }
- $res = fgets($socket, 512);
- if (substr(trim($res), 0, 3) != "+OK") {
- die($res);
- }
- fputs($socket, "USER $user\r\n");
- $res = fgets($socket, 512);
- if (substr(trim($res), 0, 3) != "+OK") {
- die($res);
- }
- fputs($socket, "PASS $pass\r\n");
- $res = fgets($socket, 512);
- if (substr(trim($res), 0, 3) != "+OK") {
- die($res);
- }
- echo "Проверка почты...<br>\r";
- fputs($socket, "STAT\r\n");
- $mails = fgets($socket, 15);
- if (substr(trim($mails), 0, 3) != "+OK") {
- die($list);
- }
- else $mails = intval(substr_replace($mails, "", 0, 4));
- echo "Писем в ящике ".$user.": ".$mails."<br><br>\r";
- for ($i = 1; $i <= $mails; $i++) {
- fputs($socket, "TOP $i 3\r\n");
- $mail = fgets($socket, 15);
- if (substr(trim($mail), 0, 3) != "+OK") {
- die($mail);
- }
- else $mail = read_socket($socket);
- $subject = decode_mime(subject_detector($mail));
- $from = decode_mime(from_detector($mail));
- echo "Письмо ".$i.": ".$subject." от ".$from."<hr>";
- }
- fclose($socket);
- die();
- ?>
Add Comment
Please, Sign In to add comment