一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

構建簡單的Webmail系統

這是一段Web Mail的示范代碼,功能不是很強,但是結構還比較完整,主要的功能如查看文件夾,查看信件,回復,寫信都有。但是程序中沒有考慮附件解讀和發送的問題。 (原文在 這里)。僅推薦給希望了解Webmail編程的網友做個參考。更加完善的Webmail請大家到 這里查找。
請注意:程序中使用了http認證功能,此功能需配合apache服務器使用。




--------------------------------------------------------------------------------
將以下代碼分別存為 index.php3, imapfuncs.phl
配置imapfuncs.phl文件中的$M_HOST = "localhost"; $M_MAILSERVER = "transit.fast.no";
然后瀏覽 index.php3 即可.  
--------------------------------------------------------------------------------
index.php3

<?php
/* $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);

?>
<HTML>
<HEAD>
<TITLE><?php echo "$M_SYSNAME"; ?></TITLE>
</HEAD>
<BODY bgcolor=#AAAAAA text=#000000 link=#440000 vlink=#440000 alink=#FF00FF>
<H1 ALIGN=CENTER><?php echo "$M_SYSNAME"; ?></H1>
<HR SIZE=1 NOSHADE>

<P>
<?php
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);
}
?>

<P>

<HR SIZE=1 NOSHADE>
<?php echo "User: $php_AUTH_USER"; ?>

</BODY>
</HTML>






--------------------------------------------------------------------------------
imapfuncs.phl

<?php /* -*-C++-*- */

/* $Id: imapfuncs.phl,v 1.4 1999/04/14 12:12:32 borud Exp $ */

/* configurable parameters */


$M_HOST = "localhost";
$M_MAILSERVER = "transit.fast.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_MBOX = "{$M_HOST:$M_PORT/$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 (! $php_AUTH_USER) {
m_reject($M_REALM);
}

$MBOX = @imap_open(m_mailbox_name($mailbox), $php_AUTH_USER, $php_AUTH_PW);

if (! $MBOX) {
m_reject($M_REALM);
}

return true;
}


function m_list($mailbox = '')
{
global $MBOX, $php_SELF;
global $M_COLOR_ODD, $M_COLOR_EVEN, $M_COLOR_HEAD, $M_COLOR_BG;

/* if not logged into server, do so */
if (! $MBOX) {
if (! m_login($mailbox)) {
return false;
}
}

$num = imap_num_msg($MBOX);

echo "<FORM ACTION=$php_SELF TYPE=POST>/n";
echo "<CENTER><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=1 WIDTH=90%>/n";

echo "<TR ALIGN=LEFT BGCOLOR=$M_COLOR_HEAD>";
echo "<TH> </TH><TH>From</TH><TH>Subject</TH><TH>Date</TH>";
echo "</TR>/n";

for ($i=1; $i < ($num+1); $i++) {
$head = imap_header($MBOX, $i, 50, 50, 0);

$from = $head->fetchfrom;
$subj = $head->fetchsubject;
$date = m_date_format($head->date);

$bgcolor = ($i%2 == 0)?$M_COLOR_ODD:$M_COLOR_EVEN;

echo "<TR BGCOLOR=/"$bgcolor/">/n";
echo " <TD><INPUT TYPE=CHECKBOX NAME=marked[] VALUE=$i></TD>/n";
echo " <TD>$from</TD>";
echo "<TD><A href=/"$php_SELF?m=$mailbox&n=$i&cmd=display/">$subj</A></TD>";
echo "<TD>$date</TD>/n";
echo "</TR>/n";
}

if ($num <= 0) {
echo "<TR><TD ALIGN=CENTER COLSPAN=4 BGCOLOR=$M_COLOR_BG><BR>";
echo "<FONT SIZE=+1 COLOR=#FF0000>No messages in mailbox</FONT>";
echo "<BR><BR></TD></TR>/n";
}

echo "<TR BGCOLOR=$M_COLOR_HEAD><TD COLSPAN=4>";
echo "<INPUT TYPE=submit NAME=cmd VALUE=delete>";
echo "<INPUT TYPE=submit NAME=cmd VALUE=compose>";
echo "<INPUT TYPE=submit NAME=cmd VALUE=refresh>";
echo "</TD></TR>/n";

echo "</TABLE></CENTER>/n";
echo "</FORM>/n";

return true;
}


function m_display($msgno, $mailbox = '')
{
global $MBOX, $M_COLOR_HEAD, $M_COLOR_BG;
global $php_SELF;

if (! $MBOX) {
if (! m_login($mailbox)) {
return false;
}
}

$struc = imap_fetchstructure($MBOX, $msgno);
if (! $struc) {
return false;
}

$head = imap_header($MBOX, $msgno, 50, 50, 0);

$from = $head->fromaddress;
$subj = $head->subject;
$date = $head->date;
$body = htmlentities(imap_body($MBOX, $msgno));

echo "<CENTER>/n";
echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=10 WIDTH=100%>/n";
echo "<TR BGCOLOR=$M_COLOR_HEAD><TH>Message #$msgno: $from / $subj</TH></TR>/n";
echo "<TR BGCOLOR=$M_COLOR_BG><TD><PRE>/n";
echo "From: $from/n";
echo "Subject: $subj/n";
echo "Date: $date/n";
echo "<HR SIZE=2 NOSHADE>/n";
echo "$body/n";
echo "</PRE></TD></TR>/n";
echo "<TR BGCOLOR=$M_COLOR_HEAD><TD>";

echo "<FORM ACTION=$php_SELF METHOD=POST>";
echo "<INPUT TYPE=HIDDEN NAME=m VALUE=$mailbox>/n";
echo "<INPUT TYPE=HIDDEN NAME=n VALUE=$msgno>/n";
echo "<INPUT TYPE=HIDDEN NAME=marked[] VALUE=$msgno>/n";
echo "<INPUT TYPE=SUBMIT NAME=cmd VALUE=back>";
echo "<INPUT TYPE=SUBMIT NAME=cmd VALUE=reply>";
echo "     <INPUT TYPE=SUBMIT NAME=cmd VALUE=delete>";

echo "</TD></TR>/n";
echo "</TABLE>/n";
echo "</CENTER>/n";

return true;
}

function m_delete ($msgno, $mailbox='')
{
global $MBOX;

if (is_array($msgno)) {
while (list($dummy, $num) = each($msgno)) {
imap_delete($MBOX, $num);
}
imap_expunge($MBOX);
} else {
return false;
}

return true;
}

function m_compose ($msgno='', $mailbox='')
{
global $MBOX, $M_COLOR_HEAD, $M_COLOR_BG;
global $php_SELF, $php_AUTH_USER, $M_MAILSERVER;

if ($msgno != '') {
$head = imap_header($MBOX, $msgno, 150, 150, 0);
$to = $head->fromaddress;
$subject = "Re: " . $head->subject;
$body = "$to wrote:/n";
$body .= ereg_replace("/n","/n>", "/n" . imap_body($MBOX, $msgno));
} else {
$to = "";
$subject = "";
$body = "";
}

echo "<CENTER>/n";
echo "<FORM METHOD=POST ACTION=/"$php_SELF/">/n";
echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=0>/n";
echo "<TR bgcolor=$M_COLOR_HEAD><TD ALIGN=RIGHT>To:</TD>";
echo "<TD><INPUT TYPE=TEXT NAME=to value=/"$to/" SIZE=50></TD></TR>/n";

echo "<TR bgcolor=$M_COLOR_HEAD><TD ALIGN=RIGHT>Subject:</TD>";
echo "<TD><INPUT TYPE=TEXT NAME=subject value=/"$subject/" SIZE=50></TD></TR>/n";

echo "<TR bgcolor=$M_COLOR_BG><TD COLSPAN=2>";
echo "<TEXTAREA COLS=76 ROWS=10 NAME=body WRAP=hard>$body</TEXTAREA>"; 

php技術構建簡單的Webmail系統,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 亚洲黄网视频 | 欧美日本高清一本二本三本 | 黄色网址在线播放 | 国产欧美久久久另类精品 | 国产精品3 | 美女视频黄色的免费 | 一区二区三区四区精品视频 | 亚洲六月丁香六月婷婷花 | 日本免费新一区二区三区 | 天天拍夜夜添久久精品中文 | 精品在线视频免费 | 久久久高清日本道免费观看 | 欧美综合激情 | 欧美色成人 | 亚洲国产精品久久久天堂 | 精品久久久久久久久中文字幕 | 四虎精品视频在线永久免费观看 | 色七影院 | 大臿蕉香蕉大视频成人 | 视频一区 在线 | 成人在线免费小视频 | 久久久亚洲国产精品主播 | 福利免费视频 | 久久综合久久精品 | 天天爽天天操 | 高清国产美女在线观看 | 久久久久中文 | 91原创视频在线 | 婷婷激情丁香 | 91视频免费观看网站 | 91福利精品老师国产自产在线 | 四虎国产精品永久在线播放 | 91精品自在拍精选久久 | 色综合999| 精品国产亚洲人成在线 | 亚洲色图偷 | 91精品啪国产在线观看免费牛牛 | 婷婷六月综合网 | 精产国品一二二区视 | 亚洲美女黄视频 | 国产精自产拍久久久久久蜜 |