Build a simple Webmail system

Source: Internet
Author: User
Tags imap
This is a demo code of WebMail. the function is not very powerful, but the structure is still relatively complete. The main functions include viewing folders, viewing letters, replying, and writing letters. However, the program does not consider the issue of attachment interpretation and sending. (The original article is here ). It is only recommended to users who want to know Webmail programming for reference. More comprehensive SyntaxHighlighter. all (); this is a demo code of Web Mail. it is not very functional, but its structure is still complete. its main functions include viewing folders, checking emails, replying, and writing letters. However, the program does not consider the issue of attachment interpretation and sending. (The original article is here ). It is only recommended to users who want to know Webmail programming for reference. For more comprehensive Webmail, please visit here.
Note: http authentication is used in the program. this function must be used with apache (the most popular WEB server platform on Unix) servers.




--------------------------------------------------------------------------------
Save the following code as index. php (as the mainstream development language) 3. imapfuncs. phl
Configure $ M_HOST = "localhost" in the imapfuncs. phl file; $ M_MAILSERVER = "transit. fast. no ";
Then browse index. php (as the mainstream development language) 3.
--------------------------------------------------------------------------------
Index. php (as the mainstream development language) 3

/* $ Id: index. php (as the mainstream development language) 3, v 1.3 12:12:32 borud Exp $ */

/* Load the IMAP library functions weve written */
Include ("imapfuncs. phl ");

M_login ($ m );

?>


<? Php (as the mainstream development language) echo "$ M_SYSNAME";?>






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 12:12:32 borud Exp $ */

/* Retriable 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 php (as the mainstream development language) 3 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 (as the mainstream development language) _ AUTH_USER, $ php (as the mainstream development language) _ AUTH_PW;

If ($ MBOX ){
Return true;
}

If (! $ Php (as the mainstream development language) _ AUTH_USER ){
M_reject ($ M_REALM );
}

$ MBOX = @ imap_open (m_mailbox_name ($ mailbox), $ php (as the mainstream development language) _ AUTH_USER, $ php (as the mainstream development language) _ AUTH_PW );

If (! $ MBOX ){
M_reject ($ M_REALM );
}

Return true;
}


Function m_list ($ mailbox =)
{
Global $ MBOX, $ php (as the mainstream development language) _ 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" ";
Echo"















";Echo" ";Echo" ";Echo" ";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" ";Echo" ";
From Subject Date

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.