//This example can be used to practice functions about IMAP
//But if you really want to write WEBMAIL, then there are more things to consider... Lone Wolf
login.php3
< ?php
if (!$PHP_AUTH_USER) {
Header("WWW-authenticate: basic realm="Mail Client Check"");
Header("HTTP/1.0 401 Unauthorized");
} else {
$MYDIR=ereg_replace("/[^/]+$","",$PHP_SELF);
Header("Location: $SERVER_NAME$MYDIR/messages.php3"); php
$MAILSERVER="{localhost/imap}";
$link=imap_open($MAILSERVER,$PHP_AUTH_USER,$PHP_AUTH_PW);
$headers=imap_headers($link);
for($x=1; $x < count($headers); $x++) {
$idx=($x-1);
echo "$headers[$idx]
";
}
?>
Connect after verification Go to the IMAP server $MAILSERVER
and then obtain the mailing list and create a connection to read the mail
view.php3:
$ MAILSERVER="{localhost/imap}";
$link=imap_open($MAILSERVER,$PHP_AUTH_USER,$PHP_AUTH_PW);
$header=imap_header($link,$num);
echo "From: $header[fromaddress]
";
echo "To: $header[toaddress]
";
echo "Date: $header[Date]
";
echo "Subject: $header[Subject]
";
echo imap_body($link,$num);
?>
view.php3 opens the IMAP connection and obtains the email header information and displays
This is only a small program that can be completed, you have to write it yourself!
http://www.bkjia.com/PHPjc/315192.html
www.bkjia.com
true