<span class="unnamed3">//这个例子可以练习关于IMAP的函数<br>//但是如果真的要写WEBMAIL,那么要考虑的东西就不止这些了……孤狼<br><br>login.php3 <br><?php <br/><br>if (!$PHP_AUTH_USER) { <br>Header("WWW-authenticate: basic realm="邮件客户检查""); <br>Header("HTTP/1.0 401 Unauthorized"); <br>} else { <br>$MYDIR=ereg_replace("/[^/]+$","",$PHP_SELF); <br>Header("Location: $SERVER_NAME$MYDIR/messages.php3"); <br>} <br><br>?> <br><br>这个进行用户检查并将用户引导到用户邮件页. <br><br>messages.php3 <br><br><?php <br/><br>$MAILSERVER="{localhost/imap}"; <br>$link=imap_open($MAILSERVER,$PHP_AUTH_USER,$PHP_AUTH_PW); <br>$headers=imap_headers($link); <br><br>for($x=1; $x $idx=($x-1); <br>echo "<a href="view.php3?num=%24x">$headers[$idx]</a><br>"; <br>} <br><br>?> <br><br>通过验证后连接到IMAP服务器$MAILSERVER <br><br>然后在取得邮件列表,并创建阅读邮件的连接 <br><br>view.php3: <br><br><?php <br/><br>$MAILSERVER="{localhost/imap}"; <br>$link=imap_open($MAILSERVER,$PHP_AUTH_USER,$PHP_AUTH_PW); <br>$header=imap_header($link,$num); <br><br>echo "From: $header[fromaddress]<br>"; <br>echo "To: $header[toaddress]<br>"; <br>echo "Date: $header[Date]<br>"; <br>echo "Subject: $header[Subject]<br><br>"; <br>echo imap_body($link,$num); <br><br>?> <br><br>view.php3打开IMAP连接并取得邮件头部信息并显示 <br><br>这Only是一个拿来完完的小程序,要完整的自己去写啦!</span> <p style="width:100%;text-align:center;margin:10px 0"> <br> <br> </p> <p style="width:100%;text-align:center;margin:10px 0"> </p> <p class="clear"></p>