How do I access my email with PHP or Connect to the mail server via sockets.

0 views
Skip to first unread message

zeesh...@gmail.com

unread,
Dec 21, 2005, 12:41:53 AM12/21/05
to phpguru
<?php
// Simple code to read mail's message using php socket
$server = "mail.abcd.com";
$user = "username";
$pass = "password";

$count = 1;
$low = 0;
$mid = 0;
$high = 100000;
$cfgTimeOut = 10;

$connection = fsockopen($server, 110, $errno, $errstr, $cfgTimeOut);

if(!$connection) {
print "Connect Failed: $errstr ($errno)";
} else {
$output = fgets($connection, 128);
fputs($connection, "USER $user\n");
$output = fgets($connection, 128);
fputs($connection, "PASS $pass\n");
$output = fgets($connection, 128);
fputs($connection, "STAT\n");
$output = fgets($connection, 128);
fputs($connection, "LIST 1\n");
$output = fgets($connection, 128);
fputs($connection, "TOP 1 10\n");
$low = 0;
while (!feof($connection)){
$output = fgets($connection,128);
print $output."<br>";
$low++;
}
fputs($connection, "QUIT\n");
$output = fgets($connection, 128);
print $output."<br>";
}
fclose($connection);
?>

Reply all
Reply to author
Forward
0 new messages