這是一段Web Mail的示範程式碼,功能不是很強,但是結構還比較完整,主要的功能如查看文件夾,查看信件,回复,寫信都有。但是程式中沒有考慮附件解讀和發送的問題。 (原文在 這裡)。僅推薦給希望了解Webmail程式的網友做個參考。更完善的Webmail請大家到 這裡找。
請注意:程式中使用了http認證功能,此功能需配合apache伺服器使用。
----------------------------------------------- ---------------------------------
將以下程式碼分別儲存為index.php3, imapfuncs.phl
設定imapfuncs.phl檔案中的$M_HOST = "localhost"; $M_MAILSERVER = "transit.fast.no";
然後瀏覽index.php3 即可.
--------- -------------------------------------------------- ---------------------
index.php3
/* $Id: index.php3,v 1.3 1999/04 /14 12:12:32 borud Exp $ */
/* load the IMAP library functions we've written */
include("imapfuncs.phl");
m_login($m); 🎜>?>
if ($cmd == "delete") {
m_delete($marked, $m);
m_list($m) ;
}
elseif ($cmd == "display") {
m_display($n, $m);
}
elseif ($cmd == "compose" || $ cmd == "reply") {
m_compose($n, $m);
}
elseif ($cmd == "send") {
m_send($to, $subject, $ body);
m_list($m);
}
else {
m_list($m);
}
?>
------------ -------------------------------------------------- ------------------
imapfuncs.phl
/* $Id: imapfuncs .phl,v 1.4 1999/04/14 12:12:32 borud Exp $ */
/* configurable parameters */
$M_HOST = "localhost";
$M_MAILSERVER$M_MAILSERVER. no";
$M_COLOR_ODD = "#CCCCCC";
$M_COLOR_EVEN = "#EEEEEE";
$M_COLOR_HEAD = "#AAAAFF";
$M_COLOR_BG = "#FFFFFF"; /* globals */
$M_PORT = 143;
$M_SERVICE = "imap";
$M_SYSNAME = "Simple PHP3 IMAP Interface 1.0";
$M_MB = "{$M_HOST = "{$M_HOST /$M_SERVICE}";
$M_REALM = "IMAP Interface";
$MBOX = false;
/* functions */
function m_login ($mailbox = '')
{
{
{
{
{
{
{
{
{
{
{
{
{
{
{
🎜>global $MBOX, $M_REALM;
global $PHP_AUTH_USER, $PHP_AUTH_PW;
if ($MBOX) {
return true;
}
if (!PPHP_AU🎜) >m_reject($M_REALM);
}
$MBOX = @imap_open(m_mailbox_name($mailbox), $PHP_AUTH_USER, $PHP_AUTH_PW);
if (! $MB_REm) { }
return true;
}
function m_list($mailbox = '')
{
global $MBOX, $PHP_SELF;
/* if not logged into server, do so */
if (! $MBOX) {
if (! m_login($mail)) { }
}
$num = imap_num_msg($MBOX);
echo "