// This example can be used to practice IMAP functions.
// But if you really want to write WEBMAIL, you have to consider more than that ...... Lone Wolf
Login. php3
<? Php
If (! $ PHP_AUTH_USER ){
Header ("WWW-authenticate: basic realm =" email client check "");
Header ("HTTP/1.0 401 Unauthorized ");
} Else {
$ MYDIR = ereg_replace ("/[^/] + $", "", $ PHP_SELF );
Header ("Location: $ SERVER_NAME $ MYDIR/messages. php3 ");
}
?>
This checks the user and directs the user to the user mail page.
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 "<a href =" view. php3? Num = $ x "> $ headers [$ idx] </a> <br> ";
}
?>
Connect to the IMAP server $ MAILSERVER after verification
Then, retrieve the email list and create a connection to read the email.
View. php3:
<? Php
$ MAILSERVER = "{localhost/imap }";
$ Link = imap_open ($ MAILSERVER, $ PHP_AUTH_USER, $ PHP_AUTH_PW );
$ Header = imap_header ($ link, $ num );
Echo "From: $ header [fromaddress] <br> ";
Echo "To: $ header [toaddress] <br> ";
Echo "Date: $ header [Date] <br> ";
Echo "Subject: $ header [Subject] <br> ";
Echo imap_body ($ link, $ num );
?>
View. php3 open the IMAP connection, obtain the mail header information, and display
This is Only a small program that has been used up. You need to write it on your own!