
IDENTIFICATION 331
Put the following PHP
script on your server:
<?php
/*
mail reader
language: PHP
*/
include('POP3.php');
// keep your personal info in a separate file:
@include_once("pwds.php");
// new instance of the Net_POP3 class:
$pop3 =& new Net_POP3();
// connect to the mail server:
$pop3->connect($host , $port);
// send login info:
$pop3->login($user , $pass , 'APOP');
// get a count of the number of new messages waiting:
$numMsgs = $pop3->numMsg();
echo "<pre>\n";
echo "Checking mail...\n";
echo "Number of messages: $numMsgs\n";
// get the headers of the first message:
echo($pop3->getRawHeaders(1));
echo "\n\n\n";
echo "</pre>\n";
// disconnect:
$pop3->disconnect();
?>
Send It
Next, make a separate file called
pwds.php on your server. This file
contains your username and password
info. Keep it separate from the main
PHP file so that you can protect it.
Format it like this:
As soon as you’ve saved the pwd.php
file, change its permissions so that only
the owner (you) can read and write
from it. From the command line, type:
chmod go-rwx pwd.php
8
<?php
$user=’username’; // your mail login
$pass=’password’; // exactly as you normally type it --
$host=’pop.example.com’; // usually pop.yourmailserver.com --
$port="110"; // this won't work on gmail.com and
// other servers using SSL
?>
Making_Things_Talk.indb 331 11/13/09 4:57 PM