【Mail】搭建郵件服務器(LAMP+Postfix+Dovcot+PostfixAdmin+Roundcubemail)

大綱 

  1、mail部署說明php

  2、安裝準備html

  3、LMAP環境配置mysql

  四、配置postfixadminlinux

  五、配置postfixweb

  6、配置dovecotsql

  7、測試SMTP和POP3服務數據庫

  8、配置Roundcubemailapache

1、mail部署說明

  •    操做系統:Linux(CentOS6.5)
  •   本例採用的是LAMP+Postfix+Dovcot+PostfixAdmin+Roundcubemail搭建的郵件服務器。閱讀本例請先參考:【Mail】郵件的基礎知識和原理
          LAMP一種軟件環境,Postfix:一種郵件傳輸代理軟件,一般用來發送郵件;Dovcot:郵件檢索代理軟件,一般用來接收郵件;PostfixAdmin:是一個基於Web的 Postfix 郵件發送服務器的管理工具;Roundcubemail:採用PHP+Ajax開發而且須要MySQL數據庫來存儲數據的email客戶端。
  •       郵件發送和接收流程以下圖:
          
               發送流程:客戶端Mail Client發出郵件 ——> Postfix接收,經過Dovecot進行認證(查詢數據庫是否存在用戶) ——> Dovecot把郵件存放在本地         (Mail Dir)
               接收流程:客戶端WebMail發出獲取郵件請求  ——> Dovecot接收請求,驗證用戶(查詢數據庫是否存在用戶)——> Dovecot把郵件從本地拿出,交給客戶端。  

2、安裝準備

  1. 添加DNS解析記錄  
    • 先添加 A 記錄 mail.yourdomain.com 解析爲你的郵件服務器IP
    • 再添加 MX 記錄指向 mail.yourdomain.com

  2. 關閉防火牆與SELinux
    • 關閉防火牆命令:service iptables stop
    • 關閉SELinux命令:vim /etc/selinux/config
  3. 配置hostname
    • 修改主機名命令:vim /etc/sysconfig/network
  4. 配置軟件源
    • 配置好yun,保證雲能正常安裝軟件


  5. 建立一個vmail用戶,用做管理虛擬郵箱的文件夾vim

      useradd  -u 2000 -d /var/vmail  -m -s /sbin/nologin  vmail

3、LMAP環境配置

         

4、配置postfixadmin

  1. 下載postfixadmin,地址:https://sourceforge.net/projects/postfixadmin/,本例使用的是postfixadmin-2.93.tar.gz。
  2. 解壓到apache的網頁目錄(/var/www/html/)並修改文件名:
    1 [root@mail ~]# tar xf postfixadmin-2.93.tar.gz -C /var/www/html/
    2 [root@mail ~]# cd /var/www/html/
    3 [root@mail html]# ls
    4 index.php  postfixadmin-2.93
    5 [root@mail html]# mv postfixadmin-2.93 postfixadmin
    6 [root@mail html]# ls
    7 index.php  postfixadmin
    8 [root@mail html]#
  3. 配置並測試
     1 [root@mail html]# cd postfixadmin/ 
     2 #修改前先備份一下配置文件 
     3 [root@mail postfixadmin]# cp config.inc.php config.inc.php.bak 
     4 [root@mail postfixadmin]# cp setup.php setup.php.bak 
     5 [root@mail postfixadmin]# vim config.inc.php 
     6 #找到下面幾行並修改 
     7 $CONF['configured'] = true; 
     8 $CONF['database_type'] = 'mysql'; 
     9 $CONF['database_host'] = 'localhost'; 
    10 $CONF['database_user'] = 'postfix'; 
    11 $CONF['database_password'] = 'postfix'; 
    12 $CONF['database_name'] = 'postfix'; 
    13 $CONF['admin_email'] = 'postmaster@free.com'; 
    14 $CONF['encrypt'] = 'dovecot:CRAM-MD5'; 
    15 $CONF['dovecotpw'] = "/usr/bin/doveadm pw"; 
    16 $CONF['domain_path'] = 'YES'; 
    17 $CONF['domain_in_mailbox'] = 'NO'; 
    18 $CONF['aliases'] = '1000'; 
    19 $CONF['mailboxes'] = '1000'; 
    20 $CONF['maxquota'] = '1000'; 
    21 $CONF['fetchmail'] = 'NO'; 
    22 $CONF['quota'] = 'YES'; 
    23 $CONF['used_quotas'] = 'YES'; 
    24 $CONF['new_quota_table'] = 'YES';
  4. 爲postfixadmin建立Mysql數據庫與權限記錄 
    • 啓動數據庫,進入數據庫
    • 建立postfix數據庫,並建立postfix用戶且受權
      1 mysql> create database postfix; 
      2 mysql> grant all on postfix.* to postfix@'localhost' identified by 'postfix'; 3 mysql> flush privileges;
    • 測試postfix可否登陸成功。
       1 [root@mail html]# mysql -u postfix -p
       2 Enter password: 3 Welcome to the MySQL monitor. Commands end with ; or \g. 4 Your MySQL connection id is 53806 5 Server version: 5.6.31 MySQL Community Server (GPL) 6 7 Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. 8 9 Oracle is a registered trademark of Oracle Corporation and/or its 10 affiliates. Other names may be trademarks of their respective 11 owners. 12 13 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 14 15 mysql> show databases; 16 +--------------------+ 17 | Database | 18 +--------------------+ 19 | information_schema | 20 | postfix | 21 | test | 22 +--------------------+ 23 3 rows in set (0.00 sec) 24 mysql> use postfix 25 Database changed 26 mysql> 

        

  5. postfixadmin具體配置流程 
    • 啓動apache,由瀏覽器進入postfix項目的設置界面,地址:http://ip:端口/postfixadmin/setup.php

      注:檢查PHP環境,並初始化數據庫
    • 能夠看出上面步驟在跟新了數據庫postfix
    • 建立設置密碼,修改配置文件的設置密碼

      點擊生成hash碼祕鑰(Generate password hash)。
    • 刷新界面,設置超級管理員帳號
    • 點擊新增,應該會出現錯誤,說沒有dovecotpw,是由於咱們還沒安裝dovecot。
    • 這裏先來安裝一下dovecot,後面再進行配置!
      1 [root@mail postfixadmin]# yum install -y  dovecot dovecot-devel dovecot-mysql 
      2 [root@mail postfixadmin]# chkconfig dovecot on #加入開機自啓動 
      3 [root@mail postfixadmin]# chkconfig dovecot --list 
      4 dovecot         0:關閉  1:關閉  2:啓用  3:啓用  4:啓用  5:啓用  6:關閉 
      5 [root@mail postfixadmin]#

       

    • 再來設置一下管理員的帳戶與密碼
    • 進入postfixadmin登入界面,地址:http://ip:端口/postfixadmin/login.php,輸入管理員帳號和密碼登陸


  6. postfxiadmin不能自動建立目錄,得增長自動創建目錄的功能 
    • 創建建立虛擬郵箱腳本,腳本名稱 /usr/local/bin/maildir-creation.sh,腳本內容以下:
      注:郵件文件就保存在HOME_DIR(及/var/vamai)中,本身能夠下載查看
       1 [root@mail ~]#vim /usr/local/bin/maildir-creation.sh 
       2 #!/bin/bash 
       3 # 
       4 HOME_DIR="/var/vmail"
       5 USER_NAME="vmail"
       6 GROUP_NAME="vmail"
       7 if [ ! -d ${HOME_DIR}/$1 ] ; then
       8     mkdir ${HOME_DIR}/$1 
       9     chown -R ${USER_NAME}.${GROUP_NAME} ${HOME_DIR}/$1 
      10 fi
      11 mkdir ${HOME_DIR}/$1/$2 
      12 chown -R ${USER_NAME}.${GROUP_NAME} ${HOME_DIR}/$1/$2
    • 創建刪除虛擬郵箱腳本,腳本名稱 /usr/local/bin/maildir-deletion.sh ,腳本內容以下:
       1 [root@mail ~]#vim /usr/local/bin/maildir-deletion.sh 
       2 #!/bin/bash 
       3 # 
       4 # vmta ALL = NOPASSWD: /usr/local/bin/maildir-deletion.sh 
       5 # 
       6 if [ $# -ne 2 ] ; then 
       7   exit 127 
       8 fi
       9 DOMAIN="$1"
      10 USER="$2"
      11 HOME_DIR="/var/vmail"
      12 USER_DIR="${HOME_DIR}/${DOMAIN}/${USER}"
      13 TRASH_DIR="${HOME_DIR}/deleted-maildirs"
      14 DATE=`date "+%Y%m%d_%H%M%S"` 
      15 if [ ! -d "${TRASH_DIR}/${DOMAIN}" ] ; then
      16     mkdir -p "${TRASH_DIR}/${DOMAIN}"
      17 fi
      18 if [ -d "${USER_DIR}" ] ; then
      19     mv ${USER_DIR} ${TRASH_DIR}/${DOMAIN}/${USER}-${DATE} 
      20 fi
  7. 創建刪除目錄
    1 [root@mail ~]# mkdir /var/vmail/deleted-maildirs 
    2 [root@mail ~]# chown -R vmail.vmail /var/vmail/deleted-maildirs/
  8. 賦予腳本可執行權限
    1 [root@mail ~]# chmod 750 /usr/local/bin/maildir-* 
    2 [root@mail ~]# chown vmail.vmail /usr/local/bin/maildir-*
  9. 配置sudo
    1 [root@mail ~]#vim /etc/sudoers 
    2 #在 /etc/sudoers 最後增長兩行 
    3 vmail ALL = NOPASSWD: /usr/local/bin/maildir-creation.sh 
    4 vmail ALL = NOPASSWD: /usr/local/bin/maildir-deletion.sh 
    5 #在/etc/sudoers 註釋掉下面內容 
    6 #Defaults    requiretty 
    7 :wq! #因爲這個文件是隻讀的,因此得強制保存並退出
  10. 修改postfixadmin的相關文件
     1 [root@mail ~]# cd /var/www/html/postfixadmin/ 
     2 [root@mail postfixadmin]# vim create-mailbox.php 
     3 修改create-mailbox.php 文件,229行內容應該是: 
     4 db_log ($SESSID_USERNAME, $fDomain, 'create_mailbox', "$fUsername"); 
     5 在該行前面增長下面一行, 
     6 system("sudo /usr/local/bin/maildir-creation.sh $fDomain ".$_POST['fUsername']); 
     7 [root@mail postfixadmin]# vim delete.php 
     8 修改delete.php 文件,146行內容應該是, 
     9 db_log ($SESSID_USERNAME, $fDomain, 'delete_mailbox', $fDelete); 
    10 在該行下面增長下面4行, 
    11 $userarray=explode("@",$fDelete); 
    12 $user=$userarray[0]; 
    13 $domain=$userarray[1]; 
    14 system("sudo /usr/local/bin/maildir-deletion.sh $domain $user");

    ------------------------------至此postfixadmin配置所有完成---------------------------瀏覽器

5、配置Postfix

  注:Postfix用CentOS6.5系統自帶的,由於CentOS6.5裏面的postfix包已經支持mysql

  1. 查看postfix版本
    1 [root@mail deleted-maildirs]# rpm -qa | grep postfix 
    2 postfix-2.6.6-6.el6_7.1.x86_64
  2. 修改postfix的配置文件
     1 [root@mail ~]# vim /etc/postfix/main.cf 
     2 #基本配置 
     3 myhostname = mail.yourdomain.com 
     4 mydomain = yourdomain.com 
     5 myorigin = $mydomain 
     6 inet_interfaces = all 
     7 mynetworks_style = host 
     8 mynetworks = 192.168.18/24, 127.0.0.0/8
     9 #虛擬域名配置 
    10 virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql_virtual_domains_maps.cf 
    11 virtual_alias_maps = proxy:mysql:/etc/postfix/mysql_virtual_alias_maps.cf 
    12 virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf 
    13 # Additional for quota support 
    14 virtual_create_maildirsize = yes 
    15 virtual_mailbox_extended = yes 
    16 virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf 
    17 virtual_mailbox_limit_override = yes 
    18 virtual_maildir_limit_message = Sorry, this user has exceeded their disk space quota, please try again later. 
    19 virtual_overquota_bounce = yes 
    20 #Specify the user/group that owns the mail folders. I'm not sure if this is strictly necessary when using Dovecot's LDA. 
    21 virtual_uid_maps = static:2000
    22 virtual_gid_maps = static:2000
    23 #Specifies which tables proxymap can read: http://www.postfix.org/postconf.5.html#proxy_read_maps 
    24 proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps 
    25 [root@mail ~]# postconf #檢查配置文件是否有錯誤
  3. 建立Mysql腳本 
    • 建立/etc/postfix/mysql_virtual_domains_maps.cf文件
      1 [root@mail ~]# vim /etc/postfix/mysql_virtual_domains_maps.cf 
      2 user = postfix 
      3 password = postfix 
      4 hosts = localhost 
      5 dbname = postfix 
      6 query = SELECT domain FROM domain WHERE domain='%s' AND active = '1'
      7 #optional query to use when relaying for backup MX 
      8 #query = SELECT domain FROM domain WHERE domain='%s' AND backupmx = '0' AND active = '1'
    • 建立/etc/postfix/mysql_virtual_alias_maps.cf文件
      1 [root@mail ~]# vim /etc/postfix/mysql_virtual_alias_maps.cf 
      2 user = postfix 
      3 password = postfix 
      4 hosts = localhost 
      5 dbname = postfix 
      6 query = SELECT goto FROM alias WHERE address='%s' AND active = '1'
    • 建立/etc/postfix/mysql_virtual_mailbox_maps.cf文件
      1 [root@mail ~]# vim /etc/postfix/mysql_virtual_mailbox_maps.cf 
      2 user = postfix 
      3 password = postfix 
      4 hosts = localhost 
      5 dbname = postfix 
      6 query = SELECT CONCAT(domain,'/',maildir) FROM mailbox WHERE username='%s' AND active = '1'
    • 建立/etc/postfix/mysql_virtual_mailbox_limit_maps.cf文件
      1 [root@mail ~]# vim /etc/postfix/mysql_virtual_mailbox_limit_maps.cf 
      2 user = postfix 
      3 password = postfix 
      4 hosts = localhost 
      5 dbname = postfix 
      6 query = SELECT quota FROM mailbox WHERE username='%s' AND active = '1'
  4. SMTP 認證設定
    SMTP(Simple Mail Transfer Protocol)即簡單郵件傳輸協議,它是一組用於由源地址到目的地址傳送郵件的規則,由它來控制信件的中轉方式 
    • 查看postfix支持的認證,默認支持dovecot
    • 1 [root@mail ~]# postconf -a 
      2 cyrus 
      3 dovecot
    • 修改/etc/postfix/main.cf配置文件
       1 [root@mail ~]#vim /etc/postfix/main.cf 
       2 #SASL SUPPORT FOR CLIENTS 
       3 # Turns on sasl authorization 
       4 smtpd_sasl_auth_enable = yes 
       5 #Use dovecot for authentication 
       6 smtpd_sasl_type = dovecot 
       7 # Path to UNIX socket for SASL 
       8 smtpd_sasl_path = /var/run/dovecot/auth-client 
       9 #Disable anonymous login. We don't want to run an open relay for spammers. 
      10 smtpd_sasl_security_options = noanonymous 
      11 #Adds support for email software that doesn't follow RFC 4954. 
      12 #This includes most versions of Microsoft Outlook before 2007. 
      13 broken_sasl_auth_clients = yes 
      14 # 
      15 smtpd_recipient_restrictions =  permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination


  5. 使用Dovecot作爲投遞
    1 [root@mail ~]# vim /etc/postfix/main.cf 
    2 # TRANSPORT MAP 
    3 virtual_transport = dovecot 
    4 dovecot_destination_recipient_limit = 1 
    5 #修改master.cf文件 
    6 [root@mail ~]# vim /etc/postfix/master.cf 
    7 #在最後增長這兩行,注意flags前面有兩個空格,否則會報錯 
    8 dovecot   unix  -       n       n       -       -       pipe, 
    9   flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/dovecot-lda -f ${sender} -d ${recipient}

    ------------------------------至此postfix配置所有完成---------------------------

6、配置Dovecot

  1. 前面已經安裝了dovecot,如今配置dovecot的配置文件 
    • 修改/etc/dovecot/dovecot.conf #主配置文件
      1 [root@mail ~]# vim /etc/dovecot/dovecot.conf 
      2 protocols = imap pop3 
      3 listen = * 
      4 dict { 
      5   quota = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext 
      6 } 
      7 !include conf.d/*.conf
    • 修改/etc/dovecot/conf.d/10-auth.conf
      1 [root@mail ~]# vim /etc/dovecot/conf.d/10-auth.conf 
      2 disable_plaintext_auth = no 
      3 auth_mechanisms = plain login cram-md5 
      4 !include auth-sql.conf.ext
    • 修改/etc/dovecot/conf.d/10-mail.conf
      1 [root@mail ~]# vim /etc/dovecot/conf.d/10-mail.conf 
      2 mail_location = maildir:%hMaildir 
      3 mbox_write_locks = fcntl
    • 修改/etc/dovecot/conf.d/10-master.conf
       1 [root@mail ~]# vim /etc/dovecot/conf.d/10-master.conf 
       2 service imap-login { 
       3   inet_listener imap { 
       4   } 
       5   inet_listener imaps { 
       6   } 
       7 } 
       8 service pop3-login { 
       9   inet_listener pop3 { 
      10   } 
      11   inet_listener pop3s { 
      12   } 
      13 } 
      14 service lmtp { 
      15   unix_listener lmtp { 
      16   } 
      17 } 
      18 service imap { 
      19 } 
      20 service pop3 { 
      21 } 
      22 service auth { 
      23   unix_listener auth-userdb { 
      24     mode = 0600 
      25     user = vmail 
      26     group = vmail 
      27   } 
      28 #新加下面一段,爲smtp作認證 
      29   unix_listener auth-client { 
      30     mode = 0600 
      31     user = postfix 
      32     group = postfix 
      33   } 
      34 } 
      35 service auth-worker { 
      36 } 
      37 service dict { 
      38   unix_listener dict { 
      39     mode = 0600 
      40     user = vmail 
      41     group = vmail 
      42   } 
      43 }
    • 修改/etc/dovecot/conf.d/15-lda.conf
      1 [root@mail ~]# vim /etc/dovecot/conf.d/15-lda.conf 
      2 protocol lda { 
      3   mail_plugins = quota
      4   postmaster_address = postmaster@free.com #管理員郵箱 
      5 }
    • 修改/etc/dovecot/conf.d/20-imap.conf
      1 [root@mail ~]# vim /etc/dovecot/conf.d/20-imap.conf 
      2 protocol imap { 
      3         mail_plugins = quota imap_quota 
      4 }
    • 修改/etc/dovecot/conf.d/20-pop3.conf
      1 [root@mail ~]# vim /etc/dovecot/conf.d/20-pop3.conf 
      2 protocol pop3 { 
      3   pop3_uidl_format = %08Xu%08Xv 
      4   mail_plugins = quota
      5 }
    • 修改/etc/dovecot/conf.d/90-quota.conf
       1 [root@mail ~]# vim /etc/dovecot/conf.d/90-quota.conf 
       2 plugin { 
       3   quota_rule = *:storage=1G 
       4 } 
       5 plugin { 
       6 } 
       7 plugin { 
       8   quota = dict:User quota::proxy::quota
       9 } 
      10 plugin { 
      11 }
    • 增長/etc/dovecot/dovecot-sql.conf.ext
      1 [root@mail ~]# vim /etc/dovecot/dovecot-sql.conf.ext 
      2 driver = mysql 
      3 connect = host=localhost dbname=postfix user=postfix password=postfix 
      4 default_pass_scheme = CRAM-MD5 
      5 user_query = SELECT CONCAT('/var/vmail/', maildir) AS home, 2000 AS uid, 2000 AS gid, CONCAT('*:bytes=', quota) as quota_rule FROM mailbox WHERE username = '%u' AND active='1'
      6 password_query = SELECT username AS user, password, CONCAT('/var/vmail/', maildir) AS userdb_home, 2000 AS userdb_uid, 2000 AS userdb_gid, CONCAT('*:bytes=', quota) as userdb_quota_rule FROM mailbox WHERE username = '%u' AND active='1'
    • 增長/etc/dovecot/dovecot-dict-sql.conf.ext
       1 [root@mail ~]# vim /etc/dovecot/dovecot-dict-sql.conf.ext 
       2 connect = host=localhost dbname=postfix user=postfix password=postfix 
       3 map { 
       4   pattern = priv/quota/storage
       5   table = quota2 
       6   username_field = username 
       7   value_field = bytes 
       8 } 
       9 map { 
      10   pattern = priv/quota/messages
      11   table = quota2 
      12   username_field = username 
      13   value_field = messages 
      14 }
  2. 從新啓動postfix和dovecot服務
    1 [root@mail ~]# service postfix restart 
    2 關閉 postfix:                                             [肯定] 
    3 啓動 postfix:                                             [肯定] 
    4 [root@mail ~]# service dovecot restart 
    5 中止 Dovecot Imap:                                        [失敗] 
    6 正在啓動 Dovecot Imap:                                    [肯定]

     ------------------------------至此dovecot配置所有完成---------------------------

7、測試SMTP和POP3服務

  1. 登陸postfixadmin,地址http://ip:端口/postfixadmin/login.php,建立虛擬域


  2. 建立測試郵箱
  3. 使用telnet 進行測試
    請參照:【Mail】telnet收發郵件過程

8、配置Roundcubemail

  1. 下載Roundcubemail(注意下載roundcubmail版本與php版本的兼容問題,本例使用的是roundcubemail-0.9.0.tar.gz),地址:https://roundcube.net,而且解壓到apache目錄中
    1 [root@mail ~]# tar -xf roundcubemail-0.9.0.tar.gz -C /var/www/html/ 
    2 [root@mail ~]# cd /var/www/html/ 
    3 [root@mail html]# ls 
    4 admin  index.php  phpmyadmin  roundcubemail-0.9.0 
    5 [root@mail html]# mv roundcubemail-0.9.0 webmail 
    6 [root@mail html]# ls 
    7 admin  index.php  phpmyadmin  webmail 
    8 [root@mail html]#
  2. 在瀏覽器中訪問roundcubemail的安裝界面,地址:http://ip:端口/webmail/installer
  3. 從上面能夠看出時區有問題,其餘都ok。因此修改php的配置文件。
    • 修改php.ini
      1 [root@mail installer]# vim /etc/php.ini 
      2 date.timezone = Asia/Shanghai

       

    • 修改apache中PHPini的位置,並重啓apache服務
      1 [root@mail installer]# vim /etc/httpd/conf/httpd.conf 
      2 PHPIniDir "/etc/php.ini"
      3 [root@mail installer]# service httpd restart 
      4 Stopping httpd:                                            [  OK  ] 
      5 Starting httpd:                                            [  OK  ] 
      6 [root@mail installer]#
  4. 修改全部Web文件的所屬者與所屬組
     1 [root@mail ~]# cd /var/www/html/ 
     2 [root@mail html]# ll 
     3 total 16 
     4 drwxrwxr-x 14 1000 1010 4096 Jul 11 05:25 admin 
     5 -rw-r--r--  1 root root   18 Jul 11 04:12 index.php 
     6 drwxr-xr-x  9 root root 4096 Jul 11 04:17 phpmyadmin 
     7 drwxr-xr-x 11  501   80 4096 Jun 16 23:10 webmail 
     8 [root@mail html]# chown -R vmail.vmail admin 
     9 [root@mail html]# chown -R vmail.vmail phpmyadmin 
    10 [root@mail html]# chown -R vmail.vmail webmail 
  5. 查看session保存位置
    1 [root@mail html]# vim /etc/php.ini 
    2 session.save_path = "/var/lib/php/session"
  6. 修改session文件的所屬組
    1 [root@mail html]# cd /var/lib/php/ 
    2 [root@mail php]# ll 
    3 total 4 
    4 drwxrwx--- 2 root apache 4096 Feb 22 10:56 session 
    5 [root@mail php]# chown -R .vmail session/ 
    6 [root@mail php]# ll 
    7 total 4 
    8 drwxrwx--- 2 root vmail 4096 Feb 22 10:56 session 
    9 [root@mail php]#
  7. 刷新roundcubemail的安裝界面,地址:http://ip:端口/webmail/installer
  8. 點擊NEXT,進行相關配置(下面是必須配置的選項) 
    • 配置webmail的顯示名稱
    • 配置Webmail數據庫相關(用戶名和密碼都是roundcude)
    • 配置IMAP
    • 配置SMTP服務器
    • 配置完成效果以下,(配置好的選項都被列出來了,咱們得下載兩個配置文件main.inc.php和db.inc.php並上傳到時服務器中)
    • 上傳至服務器相關目錄中
      1 [root@mail ~]# cd /var/www/html/webmail/config/ 
      2 [root@mail config]# ll 
      3 total 92 
      4 -rw-r--r-- 1 root  root   2905 Jul 10 22:15 db.inc.php 5 -rw-r--r-- 1 vmail vmail 2893 Jun 16 23:10 db.inc.php.dist 6 -rw-r--r-- 1 root root 38438 Jul 10 22:15 main.inc.php 7 -rw-r--r-- 1 vmail vmail 38414 Jun 16 23:10 main.inc.php.dist 8 -rw-r--r-- 1 vmail vmail 2731 Jun 16 23:10 mimetypes.php 9 [root@mail config]#
    • 給WebMail受權
      1 mysql> CREATE DATABASE roundcubemail; 
      2 Query OK, 1 row affected (0.00 sec) 
      3 mysql> GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcubemail@localhost IDENTIFIED BY 'roundcubemail'; 
      4 FLUSH PRIVILEGES;Query OK, 0 rows affected (0.01 sec) 
      5 mysql> FLUSH PRIVILEGES; 
      6 Query OK, 0 rows affected (0.00 sec)
  9. 單擊CONTINUE繼續
  10. 單擊初始化數據庫按鈕
  11. 初始化完成並用phpmyadmin查看數據庫
  12. 進行WebMail測試,地址:http://ip:端口/webmail,輸入在postfixadmin中新增的郵箱帳號和密碼。

    在roundcube裏面便可發送郵件也能夠接收郵件,就是一個網頁郵件客戶端。roundcude還有豐富的插件,能夠自行百度安裝。------------------------------至此roundcubemail配置所有完成--------------------------- 
相關文章
相關標籤/搜索