Webmail

Webmail實現源理,有三種。1、使用POP、IMAP Socket實現,2、通過直接訪問物理檔案實現,3、使用語言的開發包API實現。

基于IMAP,POP的webmail系統

SquirrelMail

SquirrelMail是使用PHP開發的webmail基于IMAP協議,對postfix,qmail....支持很好。

安裝配置SquirrelMail

  1. 下載SquirrelMail,解包後複製到Apache目錄下

    [root@linuxas3 src]# wget http://heanet.dl.sourceforge.net/sourceforge/squirrelmail/squirrelmail-1.5.0.tar.gz
    [root@linuxas3 src]# wget http://unc.dl.sourceforge.net/sourceforge/squirrelmail/zh_CN-1.4.2-20040418.tar.gz
    [root@linuxas3 src]# wget http://aleron.dl.sourceforge.net/sourceforge/squirrelmail/zh_TW-1.4.2-20040418.tar.gz
    [root@linuxas3 src]# tar zxvf squirrelmail-1.5.0.tar.gz
    [root@linuxas3 src]# tar zxvf zh_CN-1.4.2-20040418.tar.gz
    [root@linuxas3 src]# mv squirrelmail-1.5.0 /var/www/html/ squirrelmail
    [root@linuxas3 src]# ./install
    Please enter path to your squirrelmail installation:/var/www/html/squirrelmail
    [root@linuxas3 squirrelmail]# cd /var/www/html/squirrelmail
    [root@linuxas3 squirrelmail]# chmod 777 -R data
    					
  2. 進入目錄/var/www/html/squirrelmail,運行configure,顯示主菜單”Main Menu“,命令提示符Command >>

    [root@linuxas3 squirrelmail]# ./configure
    
    SquirrelMail Configuration : Read: config_default.php (1.4.0)
    ---------------------------------------------------------
    Main Menu --
    1.  Organization Preferences
    2.  Server Settings
    3.  Folder Defaults
    4.  General Options
    5.  Themes
    6.  Address Books (LDAP)
    7.  Message of the Day (MOTD)
    8.  Plugins
    9.  Database
    10. Language settings
    11. Tweaks
    
    D.  Set pre-defined settings for specific IMAP servers
    
    C.  Turn color on
    S   Save data
    Q   Quit
    
    Command >>
    					

    C. 高亮顯示

    S 保存設置

    Q 退出

  3. 在命令提示符Command >>下輸入1<CR>

    SquirrelMail Configuration : Read: config_default.php (1.4.0)
    ---------------------------------------------------------
    Organization Preferences
    1.  Organization Name      : SquirrelMail
    2.  Organization Logo      : ../images/sm_logo.png
    3.  Org. Logo Width/Height : (308/111)
    4.  Organization Title     : SquirrelMail $version
    5.  Signout Page           :
    6.  Top Frame              : _top
    7.  Provider link          : http://www.squirrelmail.org/
    8.  Provider name          : SquirrelMail
    
    R   Return to Main Menu
    C.  Turn color on
    S   Save data
    Q   Quit
    
    Command >>
    
    					

    R 反回主菜單

  4. 在命令提示符Command >>下輸入2<CR>

    SquirrelMail Configuration : Read: config.php (1.4.0)
    ---------------------------------------------------------
    Server Settings
    
    General
    -------
    1.  Domain                 : example.com
    2.  Invert Time            : false
    3.  Sendmail or SMTP       : SMTP
    
    A.  Update IMAP Settings   : localhost:143 (other)
    B.  Update SMTP Settings   : localhost:25
    
    R   Return to Main Menu
    C.  Turn color off
    S   Save data
    Q   Quit
    
    Command >> 1
    The domain name is the suffix at the end of all email addresses.  If
    for example, your email address is jdoe@myorg.com, then your domain
    would be myorg.com.
    
    [example.com]:example.net
    					

    輸入1<CR>輸入域

  5. 在命令提示符Command >>下輸入3<CR>

    SquirrelMail Configuration : Read: config.php (1.4.0)
    ---------------------------------------------------------
    Folder Defaults
    1.  Default Folder Prefix         :
    2.  Show Folder Prefix Option     : false
    3.  Trash Folder                  : INBOX.Trash
    4.  Sent Folder                   : INBOX.Sent
    5.  Drafts Folder                 : INBOX.Drafts
    6.  By default, move to trash     : true
    7.  By default, move to sent      : true
    8.  By default, save as draft     : true
    9.  List Special Folders First    : true
    10. Show Special Folders Color    : true
    11. Auto Expunge                  : true
    12. Default Sub. of INBOX         : true
    13. Show 'Contain Sub.' Option    : false
    14. Default Unseen Notify         : 2
    15. Default Unseen Type           : 1
    16. Auto Create Special Folders   : true
    17. Folder Delete Bypasses Trash  : false
    18. Enable /NoSelect folder fix   : false
    
    R   Return to Main Menu
    C.  Turn color off
    S   Save data
    Q   Quit
    
    Command >>
    					
  6. 在命令提示符Command >>下輸入4<CR>

    SquirrelMail Configuration : Read: config.php (1.4.0)
    ---------------------------------------------------------
    General Options
    1.  Data Directory              : ../data/
    2.  Attachment Directory        : $data_dir
    3.  Directory Hash Level        : 0
    4.  Default Left Size           : 150
    5.  Usernames in Lowercase      : false
    6.  Allow use of priority       : true
    7.  Hide SM attributions        : false
    8.  Allow use of receipts       : true
    9. Allow editing of identity   : true/true
    10. Allow server thread sort    : false
    11. Allow server-side sorting   : false
    12. Allow server charset search : true
    13. PHP session name            : SQMSESSID
    
    R   Return to Main Menu
    C.  Turn color off
    S   Save data
    Q   Quit
    
    Command >>
    					
  7. 在命令提示符Command >>下輸入5<CR>

    SquirrelMail Configuration : Read: config.php (1.4.0)
    ---------------------------------------------------------
    Themes
    1.  Change Themes
         Default                                     Plain Blue
         Sand Storm                                  Deep Ocean
         Slashdot                                    Purple
         Forest                                      Ice
         Sea Spray                                   Blue Steel
         Dark Grey                                   High Contrast
         Black Bean Burrito                          Servery
         Maize                                       BluesNews
         Deep Ocean 2                                Blue Grey
         Dompie                                      Methodical
         Greenhouse Effect (Changes)                 In The Pink (Changes)
         Kind of Blue (Changes)                      Monostochastic (Changes)
         Shades of Grey (Changes)                    Spice of Life (Changes)
         Spice of Life - Lite (Changes)              Spice of Life - Dark (Changes)
         Holiday - Christmas                         Darkness (Changes)
         Random (Changes every login)                Midnight
         Alien Glow                                  Dark Green
         Penguin                                     Minimal BW
    2.  CSS File :
    
    R   Return to Main Menu
    C.  Turn color off
    S   Save data
    Q   Quit
    
    Command >>
    					
  8. 在命令提示符Command >>下輸入6<CR>

    SquirrelMail Configuration : Read: config.php (1.4.0)
    ---------------------------------------------------------
    Address Books (LDAP)
    1.  Change Servers
    2.  Use Javascript Address Book Search  : false
    
    R   Return to Main Menu
    C.  Turn color off
    S   Save data
    Q   Quit
    
    Command >>
    					
  9. 在命令提示符Command >>下輸入7<CR>

    SquirrelMail Configuration : Read: config.php (1.4.0)
    ---------------------------------------------------------
    Message of the Day (MOTD)
    
    
    
    1   Edit the MOTD
    
    R   Return to Main Menu
    C.  Turn color off
    S   Save data
    Q   Quit
    
    Command >>
    					
  10. 在命令提示符Command >>下輸入8<CR>

    SquirrelMail Configuration : Read: config.php (1.4.0)
    ---------------------------------------------------------
    Plugins
      Installed Plugins
    
      Available Plugins:
        1. abook_take
        2. administrator
        3. bug_report
        4. calendar
        5. change_password
        6. filters
        7. fortune
        8. info
        9. listcommands
        10. mail_fetch
        11. message_details
        12. newmail
        13. sent_subfolders
        14. spamcop
        15. squirrelspell
        16. translate
    
    R   Return to Main Menu
    C.  Turn color off
    S   Save data
    Q   Quit
    
    Command >>
    					
  11. 在命令提示符Command >>下輸入9<CR>

    SquirrelMail Configuration : Read: config.php (1.4.0)
    ---------------------------------------------------------
    Database
    1.  DSN for Address Book   :
    2.  Table for Address Book : address
    
    3.  DSN for Preferences    :
    4.  Table for Preferences  : userprefs
    5.  Field for username     : user
    6.  Field for prefs key    : prefkey
    7.  Field for prefs value  : prefval
    
    8.  DSN for Global Address Book            :
    9.  Table for Global Address Book          : global_abook
    10. Allow writing into Global Address Book : false
    11. Allow listing of Global Address Book   : false
    
    R   Return to Main Menu
    C.  Turn color off
    S   Save data
    Q   Quit
    
    Command >>
    					
  12. 在命令提示符Command >>下輸入10<CR>

    SquirrelMail Configuration : Read: config.php (1.4.0)
    ---------------------------------------------------------
    Language settings
    1.  Default Language                : en_US
    2.  Default Charset                 : iso-8859-1
    3.  Show alternative language names : false
    4.  Available languages             : all
    5.  Use agresive decoding           : false
    
    R   Return to Main Menu
    C.  Turn color off
    S   Save data
    Q   Quit
    
    Command >>
    
    Command >> 1
    
    SquirrelMail attempts to set the language in many ways.  If it
    can not figure it out in another way, it will default to this
    language.  Please use the code for the desired language.
    
    [en_US]: zh_CN
    
    Command >> 2
    This option is obsolate. Default charset depends on language
    you have selected in "Default language" option.
    
    [iso-8859-1]: gb2312
    
    Command >> 4
    
    This option allows to limit number of languages available in
    language selection box. You can enter as code of every language that
    you want to enable. Language codes should be separated by space. If you
    enter name unsupported by SquirrelMail, it will be ignored. If you enter
    special key 'all' - all languages available in SquirrelMail will be
    listed. If you enter special key 'none' - user won't be able to changelanguage and interface will use language set it "Default language" option.
    
    Valid language names are:
     ar (Arabic), bg_BG (Bulgarian), ca_ES (Catalan), cy_GB (Welsh)
     cs_CZ (Chech), da_DK (Danish), de_DE (German), el_GR (Greek),
     en_US (English), es_ES (Spanish), et_EE (Estonian), fi_FI (Finnish),
     fo_FO (Faroese), fr_FR (French), he_IL (Hebrew), hr_HR (Croatian),
     hu_HU (Hungarian), id_ID (Indonesian), is_IS (Icelandic), it_IT (Italian),
     ja_JP (Japanese), ko_KR (Korean), lt_LT (Lithuanian), ms_MY (Malay),
     nl_NL (Dutch), nn_NO (Norwegian (Nynorsk)), no_NO (Norwegian (Bokmal)),
     pl_PL (Polish), pt_BR (Portuguese (Brazil)), pt_PT (Portuguese (Portugal)),
     ro_RO (Romanian), ru_RU (Russian), sk_SK (Slovak), sl_SI (Slovenian),
     sr_YU (Serbian), sv_SE (Swedish), th_TH (Thai), tr_TR (Turkish),
     zh_CN (Chinese Simplified), zh_TW (Chinese Traditional).
    
    [all]: zh_CN
    
    
    Command >> r
    					
  13. 在命令提示符Command >>下輸入11<CR>

    SquirrelMail Configuration : Read: config.php (1.4.0)
    ---------------------------------------------------------
    Interface tweaks
    1.  Advanced tree            : false
    2.  Oldway                   : false
    
    PHP tweaks
    3.  Use php recode functions : false
    4.  Use php iconv functions  : false
    
    R   Return to Main Menu
    C.  Turn color off
    S   Save data
    Q   Quit
    
    Command >>
    					
  14. 在命令提示符Command >>下輸入D<CR>

    SquirrelMail Configuration : Read: config.php
    ---------------------------------------------------------
    While we have been building SquirrelMail, we have discovered some
    preferences that work better with some servers that don't work so
    well with others.  If you select your IMAP server, this option will
    set some pre-defined settings for that server.
    
    Please note that you will still need to go through and make sure
    everything is correct.  This does not change everything.  There are
    only a few settings that this will change.
    
    Please select your IMAP server:
        cyrus      = Cyrus IMAP server
        uw         = University of Washington's IMAP server
        exchange   = Microsoft Exchange IMAP server
        courier    = Courier IMAP server
        macosx     = Mac OS X Mailserver
        mercury32  = Mercury/32
        quit       = Do not change anything
    Command >>
    
    					
  15. 配置webmail虛擬主機

    /etc/httpd/conf/httpd.conf

    [root@linuxas3 squirrelmail]# vi /etc/httpd/conf/httpd.conf
    NameVirtualHost xxx.xxx.xxx.xxx
    					
    <VirtualHost xxx.xxx.xxx.xxx>
        ServerAdmin webmaster@example.org
        DocumentRoot /var/www/html/squirrelmail
        ServerName webmail.example.org
        ErrorLog logs/SquirrelMail-error_log
        CustomLog logs/SquirrelMail-access_log common
    </VirtualHost>
    [root@linuxas3 squirrelmail]# service httpd restart
    Stopping httpd:                                            [  OK  ]
    Starting httpd:                                            [  OK  ]
    [root@linuxas3 squirrelmail]#
    					

    http://mail.example.org/

jwebmail

jwebmail是Java Servlet寫的Webmail跨平台很好

安裝Java環境

[root@linuxas3 src]# wget http://192.18.97.239/ECom/EComTicketServlet/BEGINjsecom16k.sun.com-2a13%3A408c6cb1%3Ada4fb41b2fe897e/-2147483648/360611139/1/444014/443834/360611139/2ts+/westCoastFSEND/j2sdk-1.4.2_04-oth-JPR/j2sdk-1.4.2_04-oth-JPR:5/j2sdk-1_4_2_04-linux-i586.bin
[root@linuxas3 src]# wget http://apache.linuxforum.net/dist/jakarta/tomcat-5/v5.0.19/bin/jakarta-tomcat-5.0.19.tar.gz
[root@linuxas3 src]# chmod 755 j2sdk-1_4_2_04-linux-i586.bin
[root@linuxas3 src]# ./j2sdk-1_4_2_04-linux-i586.bin
Do you agree to the above license terms? [yes or no]
yes (輸入 yes 解壓)
[root@linuxas3 src]# mv j2sdk1.4.2_04 ../java
[root@linuxas3 src]# tar zxvf jakarta-tomcat-5.0.19.tar.gz
[root@linuxas3 src]# mv jakarta-tomcat-5.0.19 ../jakarta-tomcat
			

配置Java環境變數

[root@linuxas3 src]# vi /etc/profile.d/java.sh
# Netkiller's envionment variables

#root=/usr/local/java

#if ! echo ${PATH} | grep -q "${root}/bin" ; then
#    PATH=${root}/bin:${PATH}
#fi

JAVA_HOME=/usr/local/java
export JAVA_HOME

JRE_HOME=/usr/local/java/jre
export JRE_HOME

APACHE_HOME=/usr/local/apache
APACHE2_HOME=/usr/local/apache

TOMCAT_HOME=/usr/local/jakarta-tomcat
CATALINA_BASE=/usr/local/jakarta-tomcat
CATALINA_HOME=/usr/local/jakarta-tomcat
export TOMCAT_HOME CATALINA_BASE CATALINA_HOME


ANT_HOME=/usr/local/apache-ant
export ANT_HOME

JAMES_HOME=/usr/local/james
export JAMES_HOME

CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/pg73jdbc3.jar:$TOMCAT_HOME/webapps:/usr/local/jakarta-tomcat/common/classes/pg73jdbc3.jar:/usr/local/jakarta-tomcat/common/classes/mysql-connector-java-3.0.8-stable-bin.jar:/var/www/html/webapps/WEB-INF/lib/jfreechart-0.9.16.jar:/var/www/html/webapps/WEB-INF/lib/jcommon-0.9.1.jar:/var/www/html/webapps/WEB-INF/lib/gnujaxp.jar

CLASSPATH=$CLASSPATH:/var/www/html/webapps/WEB-INF/lib:/var/www/html/webapps/WEB-INF/classes

export CLASSPATH

MYSQL_HOME=/usr/local/mysql

PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$ANT_HOME/bin:MYSQL_HOME/bin
export PATH

			

部屬webmail.war

[root@linuxas3 src]# wget http://umn.dl.sourceforge.net/sourceforge/jwebmail/webmail-0.7.10-binary.tar.gz
[root@linuxas3 src]# tar zxvf webmail-0.7.10-binary.tar.gz
webmail.war
INSTALL
[root@linuxas3 src]# mv webmail.war /usr/local/jakarta-tomcat/webapps/
[root@linuxas3 src]#
			

啟動Tomcat

[root@linuxas3 src]# /usr/local/jakarta-tomcat/bin/startup.sh
Using CATALINA_BASE:   /usr/local/jakarta-tomcat
Using CATALINA_HOME:   /usr/local/jakarta-tomcat
Using CATALINA_TMPDIR: /usr/local/jakarta-tomcat/temp
Using JAVA_HOME:       /usr/local/java
[root@linuxas3 src]#
			

測試URL

http://mail.example.org:8080/webmail

Horde IMP

imp 也是一個PHP寫的WEBMAIL