• 0

POP3 in PHP


Question

Can someone show me some code or a website telling me how to return a value of the number of messages on a POP3 Server.

So I can put something on a front page that says ' You have 3 Messages '.

Thanks in advance.

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Well, that was quick :D

Mind sharing how you were able to do it? (I assume you opened up a socket and just few raw commands...)

Link to comment
Share on other sites

  • 0

Timdorr, I used this bit of code, obviously filling in the $ below to your POP settings.

<?

// mail server settings

$host="Your POP Host";

$port = 110;

$user = "Your Username";

$pass = "Your Password";

// open a client connection

$fp = fsockopen ($host, $port, $errno, $errstr);

// if a handle is not returned

if (!$fp)

{

die("Error: could not open socket connection\n");

}

else

{

// get the welcome message

$welcome = fgets ($fp, 150);

// check for success code

if (substr($welcome, 0, 3) == "+OK")

{

// send username and read response

fputs ($fp, "USER $user\n");

fgets($fp, 50);

// send password and read response

fputs ($fp, "PASS $pass\n");

$ack = fgets($fp, 50);

// check for success code

if (substr($ack, 0, 3) == "+OK")

{

// send status request and read response

fputs ($fp, "STAT\n");

$status = fgets($fp, 50);

if (substr($status, 0, 3) == "+OK")

{

// shut down connection

fputs ($fp, "QUIT\n");

fclose ($fp);

}

// error getting status

else

{

die ("Server said: $status");

}

}

// auth failure

else

{

die ("Server said: $ack");

}

}

// bad welcome message

else

{

die ("Bad connection string\n");

}

// get status string

// split by spaces

$arr = explode(" ", $status);

// the second element contains the total number of messages

echo $arr[1] . " messages in mailbox";

}

?>

Timdorr, can you give me a hand <Timdorr starts clapping, LOL !>

I have a page on my active desktop and now my icon text background has gone a solid grey and so has the shadow of the icons, the shadows are no longer smooth as they should be in XP.

Also I need to know how to make the page refresh every 5 mins, is their a different way then setting an active desktop schedule, ie: a command in the page.

Kind regards

Link to comment
Share on other sites

  • 0

seen as you are using php, the following should work ok

header("Refresh: 300; url=<thispage.php>");

i think it has to be the first line of the page that gets processed.

Link to comment
Share on other sites

  • 0

Actually, I think windowfx 2 (from stardock) *might* be able to do that. check out the shareware version and see if it does....

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.