Źródło:


Komentarze (0)


Ocena:
0

źródło pochodzi od: sympozjon

Opis:
Klasa umożliwa przeglądanie maili.

Język: php


A class to allow you to connect to POP3 servers

# Written by someone on some newsgroup, but modified by me,
# Kevin McDermott kevin@kidojo.com

class Pop3 {
var $user;
var $pass;
var $Socket; // the current socket

var $Line;
var $Status;
var $Banner;

function Pop3($Server = "localhost",$Port = 110)
{   
return $this->pop3_open($Server, $Port);
}

# This will handle the connection process for you, just feed it the
# information it needs. It will default to APOP secure connection but
# fall back to plain text if that doesn't work.  WARNING: some servers
# will kick you out after one failed attempt so after the failed APOP
# authentication, you'll be kicked out, and this will fail, disable
# APOP authentication if this is the case, and APOP doesn't work.
function Pop3($Server = "localhost", $Port = 110, $user = "", $pass = "") {
if ( !$this->pop3_open($Server, $Port) ) {
$this->Status["Connection"] =
    "Could not contact server '$Server' on port $Port";
return;
}

if (false && $this->Banner) { # disable this pending further APOP tests
if (!$this->pop3_apop($user, $pass)) {
if ( !$this->pop3_user($user) ) {
$this->Status["Connection"] = "Username '$user' is invalid";
return;
}
if ( !$this->pop3_pass($pass) ) {
$this->Status["Connection"] =
    "Username '$user' or Password is invalid";
return;
}
}
} else {
if ( !$this->pop3_user($user) ) {
$this->Status["Connection"] = "Username '$user' is invalid";
return;
}
if ( !$this->pop3_pass($pass) ) {
$this->Status["Connection"] =
    "Username '$user' or Password is invalid";
return;
}
}
return true;
}

function pop3_open($server, $port
{

$this->Socket = fsockopen($server, $port);
if ($this->Socket <= 0){
return false;
}
$this->Line = fgets($this->Socket, 1024);
$this->Status["LASTRESULT"] = substr($this->Line, 0, 1);
$this->Status["LASTRESULTTXT"] = substr($this->Line, 0, 1024);
if (preg_match("/<[wd-.]+@[wd-.]+>/",
$this->Status["LASTRESULTTXT"], $matched)) {
$this->Banner = $matched[0];
} else {
$this->Banner = "";
}

if ($this->Status["LASTRESULT"] <> "+") return false;
return true;
}

function pop3_user($user)
{
$this->user = $user;
if ($this->Socket < 0){
  return false;
}
fputs($this->Socket, "USER $this->userrn");
$this->Line = fgets($this->Socket, 1024);
$this->Status["LASTRESULT"] = substr($this->Line, 0, 1);
$this->Status["LASTRESULTTXT"] = substr($this->Line, 0, 1024);

if ($this->Status["LASTRESULT"] <> "+") return false;

return true;
}

function pop3_pass($pass)
{
$this->pass = $pass;
fputs($this->Socket, "PASS $this->passrn");
$this->Line = fgets($this->Socket, 1024);
$this->Status["LASTRESULT"] = substr($this->Line, 0, 1);
$this->Status["LASTRESULTTXT"] = substr($this->Line, 0, 1024);

if ($this->Status["LASTRESULT"] <> "+") return false;

return true;
}
function pop3_apop($user, $pass)
{
fputs($this->Socket, "APOP $user ".md5($this->Banner.$pass)."rn");
$this->Line = fgets($this->Socket, 1024);
$this->Status["LASTRESULT"] = substr($this->Line, 0, 1);
$this->Status["LASTRESULTTXT"] = substr($this->Line, 0, 1024);

if ($this->Status["LASTRESULT"] <> "+") return false;

return true;
}
function pop3_stat()
{

fputs($this->Socket, "STATrn");
$this->Line = fgets($this->Socket, 1024);
$this->Status["LASTRESULT"] = substr($this->Line, 0, 1);
$this->Status["LASTRESULTTXT"] = substr($this->Line, 0, 1024);

if ($this->Status["LASTRESULT"] <> "+") return false;

if (!eregi("+OK (.*) (.*)", $this->Line, $regs))
return false;

return $regs[1];
}

function pop3_list()
{
fputs($this->Socket, "LISTrn");
$this->Line = fgets($this->Socket, 1024);
$this->Status["LASTRESULT"] = substr($this->Line, 0, 1);
$this->Status["LASTRESULTTXT"] = substr($this->Line, 0, 1024);

if ($this->Status["LASTRESULT"] <> "+") return false;

$i = 0;
while (substr($this->Line = fgets($this->Socket, 1024), 0, 1) <> ".") {
$articles[$i] = $this->Line;
$i++;
}

return $articles;
}

# This retreaves the whole message, and sets the Status: field in the
# message to read (it adds an 'R' to that field).
function pop3_retr($nr)
{

fputs($this->Socket, "RETR $nrrn");
$this->Line = fgets($this->Socket, 1024);
$this->Status["LASTRESULT"] = substr($this->Line, 0, 1);
$this->Status["LASTRESULTTXT"] = substr($this->Line, 0, 1024);

if ($this->Status["LASTRESULT"] <> "+") return 0;

while (substr($this->Line = fgets($this->Socket, 1024), 0, 1) <> ".") {
$data[$i] = $this->Line;
$i++;
}

return $data;
}

# This will view the header of a message (and $lines number of lines
# afterwards WITHOUT setting the Status: field as read (doesn't add an 'R'
# to that field.
function pop3_top($nr, $lines)
{

fputs($this->Socket, "TOP $nr $linesrn");
$this->Line = fgets($this->Socket, 1024);
$this->Status["LASTRESULT"] = substr($this->Line, 0, 1);
$this->Status["LASTRESULTTXT"] = substr($this->Line, 0, 1024);

if ($this->Status["LASTRESULT"] <> "+") return 0;

while (substr($this->Line = fgets($this->Socket, 1024), 0, 1) <> ".") {
$data[$i] = $this->Line;
$i++;
}

return $data;
}

function pop3_dele( $nr)
{

fputs($this->Socket, "DELE $nrrn");
$this->Line = fgets($this->Socket, 1024);
$this->Status["LASTRESULT"] = substr($this->Line, 0, 1);
$this->Status["LASTRESULTTXT"] = substr($this->Line, 0, 1024);

if ($this->Status["LASTRESULT"] <> "+") return 0;
return 1;
}

function pop3_quit()
{

fputs($this->Socket, "QUITrn");
$this->Line = fgets($this->Socket, 1024);
$this->Status["LASTRESULT"] = substr($this->Line, 0, 1);
$this->Status["LASTRESULTTXT"] = substr($this->Line, 0, 1024);

if ($this->Status["LASTRESULT"] <> "+") return 0;

return 1;
}
}

</body>
</html>
powrót

Tagi do źródła:
Przeglądanie e-maili, mail, pop3, php


Nikt jeszcze nie skomentował tego źródła.


assembler baza danych bot c crawler delphi html java kontakt box loader mail obsługa sieci obsługa zapyt(..) own os php pop3 porównywanie (..) przeszukiwanie(..) robot sieciowy rozmowa symulator rozm(..) system operacy(..) voteban stop wysyłanie e-m(..) boot dekodowanie mim(..) java juzef kolejny skrypt (..) mysql pobieranie zawa(..) przeglądanie e(..) sdl whois wysyłanie e-ma(..)

Wszystkie...


sources.pl to strona przeznaczona dla programistów, początkujących programistów i zupełnych amatorów programowania. Tu możesz umieścić swój kod, program napisany przez Ciebie, lub po prostu skomentować kod innego programisty.

Szukaj:


Źródeł: 30, oczekujących: 3, odrzuconych: 11

O stronie | kontakt |

Sources.pl

Ilość wejść: dzisiaj - 380 (unikalne: 173), ogółem - 753209 (unikalne: 655692)