A simple webmail system Source: Sadly This is a web mail demonstration code, the function is not very strong, but the structure is complete, the main functions such as viewing folders, view letters, reply, write letters. However, there is no problem with attachment interpretation and transmission. (Originally here). Recommend only for users who want to understand Webmail programming to make a reference. More complete webmail, please find it here. Note: HTTP authentication features are used in the program, which needs to be used with the Apache server.
-------------------------------------------------- ------------------------------ The following code is stored as index.php3, iMapFuncs.phl configuration imapfuncs.phl file $ M_host = "localhost"; $ m_mailserver = "transit.fast.no"; then browse 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);
?>
PHPIF ($ 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);}?>
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 = "#fffff";
/ * 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 "