Linux 郵件服務器搭建超詳細文檔

1. 配置ip地址192.168.1.2  setup配置ip
更改主機名
Vim /etc/sysconfig/network
mail.han.com
更改參數vim /etc/selinux/config
SELINUX=disabled
重啓系統 reboot 使其參數生效
(history | grep configure查看編譯安裝文件)
2. 編譯安裝mysql
卸載已安裝的mysql的RPM包
[root@server01 /]# rpm -qa | grep mysql 首先查看系統中是否已安裝mysql服務器軟件
執行卸載
[root@server01 /]# rpm -e mysql-server
[root@server01 /]# rpm -e mysql-connector-odbc
[root@server01 /]# rpm -e libdbi-dbd-mysql
[root@server01 /]# rpm -e mysql --nodeps
刪除RPM包創建的mysql賬號
[root@server01 /]# userdel -r mysql
釋放MySQL軟件包
[root@server01]  cd /tool/
[root@server01 tool]# tar -zxvf mysql-5.0.56.tar.gz
添加MySQL用戶和組,用於運行和維護mysql服務
[root@server01 tool]# useradd -M -s /sbin/nologin mysql
-M 選項表示不建立用戶宿主目錄、-s 選項表示指定用戶的shell
編譯前的預配置
[root@server01] # cd  mysql-5.0.56
[root@server01 mysql-5.0.56]# ./configure --prefix=/usr/local/mysql
編譯並安裝
[root@server01 mysql-5.0.56]# make && make install
建立mysql配置文件
[root@server01 mysql-5.0.56]# cp support-files/my-medium.cnf /etc/my.cnf
初始化mysql數據庫
以mysql用戶的身份執行mysql_install_db腳本,對MySQL數據庫進行初始化
[root@server01 mysql-5.0.56]# cd /usr/local/mysql/bin/
[root@server01 bin]# ./mysql_install_db --user=mysql
調整mysql目錄權限
修改相關目錄的所有權,以便mysql用戶可以讀寫數據庫
調整/usr/loca/mysql目錄的權限:
[root@server01 local]# ls -ld /usr/local/mysql/
[root@server01 local]# chown -R root.mysql /usr/local/mysql
[root@server01 local]# ls -ld /usr/local/mysql/
調整/usr/local/mysql/var目錄的權限:
[root@server01 local]# chown -R mysql /usr/local/mysql/var/
[root@server01 local]# ls -ld /usr/local/mysql/var
調整lib庫路徑
[root@server01 local]# vi /etc/ld.so.conf
添加路徑:
/usr/local/mysql/lib/mysql
[root@server01 local]# ldconfig
Mysql的啓動控制
(1) 使用mysqld_safe腳本安全啓動服務
[root@mail /]# /usr/local/mysql/bin/mysqld_safe --user=mysql &
(2) 設置MySQL程序的執行路徑,主要是爲了在執行mysql管理工具時方便
方法一:修改配置文件/etc/profile,使配置永久生效
[root@server01 local]# vi /etc/profile
添加:
PATH=$PATH:/usr/local/mysql/bin
[root@server01 local]# source /etc/profile
方法二:執行export命令,使配置僅當前生效
[root@server01 local]#export PATH=$PATH:/usr/local/mysql/bin
(3) 將Mysql添加爲系統服務,主要是爲了mysql服務啓動的方便
[root@server01 local]# cd /tool/mysql-5.0.56
[root@server01 mysql-5.0.56]# cp support-files/mysql.server /etc/init.d/mysqld
[root@server01 mysql-5.0.56]# chmod +x /etc/init.d/mysqld
[root@server01 mysql-5.0.56]# chkconfig --add mysqld
[root@server01 mysql-5.0.56]# chkconfig mysqld on
測試一下mysql
登陸及退出mysql數據庫環境
[root@server01 /]# mysql -u root
以管理員root第一次登陸默認是沒有密碼的,直接執行上面的命令即可;
退出mysql環境的話:可以使用exit或ctrl+c
爲mysql數據庫的默認管理員root設置密碼
[root@server01 /]# mysqladmin -u root password "123456"
[root@server01 /]# mysql -u root -p
3.安裝DNS rpm包方式安裝
掛載光盤 mount /dev/cdrom /media/
需要安裝的DNS相關rpm包
bind-utils-9.3.6-4.P1.el5    提供DNS服務器的測試工具程序(nslookup、dig等)
bind-chroot-9.3.6-4.P1.el5    實現bind根目錄的監牢機制,增強安全性
bind-libs-9.3.6-4.P1.el5    bind軟件程序所需要的lib庫文件
bind-9.3.6-4.P1.el5        提供了域名服務的主要程序和相關文件
rpm -ivh /media/Server/caching-nameserver-9.3.6-4.P1.el5.i386.rpm
[root@mail /]# cd /var/named/chroot/etc/
[root@mail etc]# cp -p named.caching-nameserver.conf named.conf
[root@mail etc]# vim named.conf
options {
        listen-on port 53 { 192.168.1.2; };
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        allow-query     { any; };
        allow-query-cache { any; };
};
zone "han.com" IN {
      type master;
      file "han.zx";
};
zone "1.168.192.in-addr.arpa" IN {
      type master;
      file "han.fx";
};
[root@mail etc]# cd /var/named/chroot/var/named/
[root@mail named]# cp -p localhost.zone han.zx
[root@mail named]# vim han.zx (DNS正向區域設置)
$TTL    86400
@               IN SOA han.com. root.han.com. (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum

@               IN NS           mail.han.com
mail            IN A            192.168.1.2
@               IN MX 10        mail.han.com
[root@mail named]# cp -p han.zx han.fx
[root@mail named]# vim han.fx (DNS反向區域設置)
$TTL    86400
@               IN SOA han.com. root.han.com. (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum

@               IN NS           mail.han.com
2               IN PTR          mail.han.com
啓動DNS服務
[root@mail named]# service named restart
4.創建運行郵件系統的用戶賬號postfix及用戶組postfix和postdrop
[root@server01 /]# groupadd -g 1200 postdrop
[root@server01 /]# groupadd -g 1000 postfix
[root@server01 /]# useradd -M -u 1000 -g postfix -G postdrop -s /sbin/nologin postfix
5.編譯安裝postfix
[root@server01 tool]# tar zxvf postfix-2.4.6.tar.gz
[root@server01 tool]# gunzip postfix-2.4.6-vda-ng.patch.gz
[root@server01 tool]# cd postfix-2.4.6
[root@server01 postfix-2.4.6]# patch -p1 < ../postfix-2.4.6-vda-ng.patch
產生postfix編譯前的makefiles配置文件
[root@server01 postfix-2.4.6]# make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl' 'AUXLIBS=-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2'
編譯和編譯安裝
[root@server01 postfix-2.4.6]# make && make install
使用postconf工具簡化postfix配置文件main.cf,只保留與默認配置不同的參數,提高易讀性和可編輯性
[root@server01 /]# cd /etc/postfix/
[root@server01 postfix]# postconf -n > main2.cf
[root@server01 postfix]# mv main.cf main.cf.bak
[root@server01 postfix]# mv main2.cf main.cf
[root@mail postfix]# vim main.cf 添加相關參數
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
debug_peer_level = 2
html_directory = no
mail_owner = postfix
mailq_path = /usr/bin/mailq
manpage_directory = /usr/local/man
newaliases_path = /usr/bin/newaliases
queue_directory = /var/spool/postfix
readme_directory = no
sample_directory = /etc/postfix
sendmail_path = /usr/sbin/sendmail
setgid_group = postdrop
unknown_local_recipient_reject_code = 550
inet_interfaces=192.168.1.2,127.0.0.1
myhostname=mail.han.com
mydomain=han.com
myorigin=$mydomain
mydestination=$mydomain,$myhostname
home_mailbox=Maildir/
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
[root@mail postfix]# postfix start 啓動postfix服務
查看服務啓動後打開的端口
[root@mail postfix]# netstat -antp | grep 25
執行命令產生別名數據庫文件aliases.db
[root@server01 ~]# newaliases
[root@server01 ~]# ls /etc/aliases.db
重新加載配置
[root@server01 postfix]# postfix reload
建立郵件用戶,通過telnet方法發送電子郵件測試
[root@server01 postfix]# useradd -s /sbin/nologin mail01
[root@server01 postfix]# passwd mail01
[root@server01 postfix]# useradd -s /sbin/nologin mail02
[root@server01 postfix]# passwd mail02
[root@server01 /]# telnet 127.0.0.1 25
SMTP常用命令字:
HELO localhost   宣告客戶端主機地址
MAIL FROM:       發件人地址
RCPT TO:         收件人地址
DATA             郵件數據
QUIT             退出
6.編譯安裝http
卸載已安裝的apache的RPM包
[root@server01 tool]# rpm -e system-config-httpd
[root@server01 tool]# rpm -e httpd-manual
[root@server01 tool]# rpm -e httpd –nodeps
[root@mail tool]# tar -zxvf httpd-2.2.9.tar.gz
編譯前的預配置
[root@mail tool]# cd httpd-2.2.9
[root@mail httpd-2.2.9]# ./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --enable-cgi --enable-suexec --with-suexec-caller=daemon --with-suexec-docroot=/usr/local/apache/htdocs
[root@mail httpd-2.2.9]# make && make install
[root@mail httpd-2.2.9]# vim /usr/local/apache/conf/httpd.conf 修改
ServerName mail.han.com:80
啓動apache服務
[root@mail /]# /usr/local/apache/bin/apachectl start
7.編譯安裝php
[root@mail tool]# tar -jxvf php-5.2.6.tar.bz2
[root@mail tool]# cd php-5.2.6
[root@mail php-5.2.6]# ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql/ --enable-sockets --enable-mbstring
編譯並安裝
[root@mail php-5.2.6]# make && make install
複製php.ini配置文件
[root@mail php-5.2.6]# cp php.ini-dist /usr/local/php5/php.ini
添加並設置
[root@mail php-5.2.6]# vim /usr/local/apache/conf/httpd.conf
LoadModule php5_module        modules/libphp5.so
AddType  application/x-httpd-php  .php
DirectoryIndex index.html index.php
重啓apache服務器
[root@mail php-5.2.6]# /usr/local/apache/bin/apachectl restart
8.編譯安裝dovecot
卸載當前系統已安裝的dovecot的rpm包
[root@mail /]# rpm -e dovecot
[root@mail tool]# useradd -M -s /sbin/nologin dovecot
[root@mail tool]# tar -zxvf dovecot-1.1.4.tar.gz
[root@mail tool]# cd dovecot-1.1.4
[root@mail dovecot-1.1.4]# ./configure --sysconfdir=/etc --with-mysql
[root@mail dovecot-1.1.4]# make && make install
配置dovecot的運行參數
從dovecot的模板配置文件生成簡單配置文件
[root@mail dovecot-1.1.4]# cp /etc/dovecot-example.conf /etc/dovecot.conf
[root@mail dovecot-1.1.4]#  vi /etc/dovecot.conf
protocols = imap pop3
ssl_disable = yes
disable_plaintext_auth = no
mail_location = maildir:~/Maildir
創建dovecot的PAM認證文件
[root@mail dovecot-1.1.4]# vi /etc/pam.d/dovecot
auth    required        pam_nologin.so
auth    include         system-auth
account include         system-auth
session include         system-auth
啓動dovecot服務
[root@mail dovecot-1.1.4]# dovecot -c /etc/dovecot.conf
查看dovecot服務開啓的端口
[root@mail dovecot-1.1.4]# netstat -antp | grep dovecot
9.配置Postfix虛擬用戶支持
[root@mail tool]# tar -zxvf extman-0.2.5.tar.gz
[root@mail tool]# cd extman-0.2.5
[root@mail extman-0.2.5]# cd docs/
[root@mail docs]# pwd
[root@mail docs]# mysql -u root -p < extmail.sql
[root@mail docs]# mysql -u root -p < init.sql
修改postfix配置文件main.cf,添加支持虛擬用戶的參數
[root@mail docs]# vi /etc/postfix/main.cf
smtpd_sasl_application_name = smtpd
smtpd_sasl_local_domain = $myhostname
virtual_mailbox_base = /mailbox
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_uid_maps = static:1000
virtual_gid_maps = static:1000
刷新
[root@mail docs]# postfix reload
把已存在的樣例模板文件複製到/etc/postfix目錄下
[root@mail docs]# cp mysql_virtual_* /etc/postfix/
爲虛擬用戶設置SMTP發信認證
編譯安裝 courier-authlib
[root@mail tool]# tar -jxvf courier-authlib-0.60.2.tar.bz2
[root@mail tool]# cd courier-authlib-0.60.2
[root@mail courier-authlib-0.60.2]# ./configure --prefix=/usr/local/courier-authlib --without-stdheaderdir --with-authmysql --with-redhat --with-mysql-libs=/usr/local/mysql/lib/mysql --with-mysql-include=/usr/local/mysql/include/mysql
[root@mail  courier-authlib-0.60.2]# make && make install
[root@mail  courier-authlib-0.60.2]# make install-configure
增加路徑:
/usr/local/courier-authlib/lib/courier-authlib
[root@mail /]# ldconfig
[root@mail courier-authlib-0.60.2]# cd /usr/local/courier-authlib/etc/authlib/
[root@mail authlib]# cp authdaemonrc authdaemonrc.bak
[root@mail authlib]#  vim authdaemonrc
authmodulelist="authmysql"
authmodulelistorig="authmysql"
[root@mail authlib]# chmod -R 755 /usr/local/courier-authlib/var/spool/authdaemon/
修改配置文件authmysqlrc,設置如何向mysql數據庫查詢信息
[root@mail authlib]# cp authmysqlrc authmysqlrc.bak
[root@mail authlib]# vim authmysqlrc
修改以下參數
MYSQL_SERVER            localhost
MYSQL_USERNAME          extmail
MYSQL_PASSWORD          extmail
MYSQL_SOCKET            /tmp/mysql.sock
MYSQL_DATABASE          extmail
MYSQL_USER_TABLE        mailbox
MYSQL_CRYPT_PWFIELD     password
MYSQL_UID_FIELD         uidnumber
MYSQL_GID_FIELD         gidnumber
MYSQL_LOGIN_FIELD       username
MYSQL_HOME_FIELD        concat('/mailbox/',homedir)
MYSQL_NAME_FIELD        name
MYSQL_MAILDIR_FIELD     concat('/mailbox/',maildir)
[root@mail authlib]# chown daemon.daemon authmysqlrc
複製courier-authlib腳本,並啓動courier-authlib服務
[root@mail authlib]# cd /tool/courier-authlib-0.60.2
[root@mail courier-authlib-0.60.2]# cp courier-authlib.sysvinit /etc/init.d/courier-authlib
[root@mail courier-authlib-0.60.2]# chmod 755 /etc/rc.d/init.d/courier-authlib
[root@mail courier-authlib-0.60.2]# chmod 755 /etc/init.d/courier-authlib
[root@mail courier-authlib-0.60.2]# chkconfig --add courier-authlib
[root@mail courier-authlib-0.60.2]# chkconfig --level 35 courier-authlib on
[root@mail courier-authlib-0.60.2]# service courier-authlib start
[root@mail courier-authlib-0.60.2]# vi /usr/lib/sasl2/smtpd.conf
pwcheck_method:authdaemond
authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket
調整socked目錄的權限
[root@mail /]# chmod -R 755 /usr/local/courier-authlib/var/spool/authdaemon/
重新啓動courier-authlib服務
[root@mail /]# service courier-authlib restart
測試
[root@mail /]# /usr/local/courier-authlib/sbin/authtest -s login [email protected]  extmail
配置dovecot,調整郵件存儲位置及其他參數
[root@mail /]# vim /etc/dovecot.conf
添加並修改參數如下
mail_location = maildir:/mailbox/%d/%n/Maildir
auth default {        (刪除註釋到%87)
  mechanisms = plain
  passdb sql {
     args = /etc/dovecot-mysql.conf
  }
  userdb sql {
     args = /etc/dovecot-mysql.conf
  }
}
設置配置文件/etc/dovecot-mysql.conf
[root@mail /]# cd /etc
[root@mail etc]# touch dovecot-mysql.conf
[root@mail etc]# vi dovecot-mysql.conf
driver = mysql
connect = host=localhost dbname=extmail user=extmail password=extmail
default_pass_scheme = CRYPT
password_query = SELECT username AS user,password AS password FROM mailbox WH
ERE username = '%u'
user_query = SELECT maildir,uidnumber AS uid,gidnumber AS gid FROM mailbox WH
ERE username = '%u
建立虛擬用戶的郵箱目錄
[root@mail etc]# mkdir -p /mailbox/extmail.org/postmaster/Maildir/
[root@mail etc]# chown -R postfix:postfix /mailbox/
[root@mail etc]# killall dovecot
[root@mail etc]# dovecot
測試對虛擬用戶的SMTP發信認證
獲得虛擬“用戶[email protected]密碼extmail”的加密的字符串
有2種方法可以獲取:
方法一:
[root@mail /]# cd /usr/local/courier-authlib/etc/authlib/
[root@mail  authlib]# printf "[email protected]" | openssl base64
[root@mail  authlib]# printf "extmail" | openssl base64
方法二:
[root@mail authlib]# perl -e 'use MIME::Base64; print encode_base64("[email protected]")'
[root@mail  authlib]# perl -e 'use MIME::Base64; print encode_base64("extmail")'
測試:
[root@mail authlib]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 mail.han.com ESMTP Postfix
auth login
334 VXNlcm5hbWU6
cG9zdG1hc3RlckBleHRtYWlsLm9yZw==
334 UGFzc3dvcmQ6
ZXh0bWFpbA==
235 2.0.0 Authentication successful
quit 退出
10.Extmail郵件使用及管理平臺
安裝Unix-Syslog-1.1.tar.gz
[root@mail tool]# tar -zxvf Unix-Syslog-1.1.tar.gz
[root@mail tool]# cd Unix-Syslog-1.1
[root@mail Unix-Syslog-1.1]# perl Makefile.PL
[root@mail Unix-Syslog-1.1]# make && make install
安裝DBI-1.607.tar.gz
[root@mail tool]# tar -zxvf DBI-1.607.tar.gz
[root@mail tool]# cd DBI-1.607
[root@mail DBI-1.607]# perl Makefile.PL
[root@mail DBI-1.607]# make && make install
安裝DBD-mysql-4.011.tar.gz
[root@mail tool]# tar -zxvf DBD-mysql-4.011.tar.gz
[root@mail tool]# cd DBD-mysql-4.011
[root@mail DBD-mysql-4.011]# perl Makefile.PL
[root@mail DBD-mysql-4.011]# make && make install
安裝並配置extmail套件
[root@mail tool]# tar -zxvf extmail-1.0.5.tar.gz -C /usr/local/apache/htdocs/
[root@mail tool]# cd /usr/local/apache/htdocs/
[root@mail htdocs]# mv extmail-1.0.5/ extmail
[root@mail htdocs]# cd extmail/
[root@mail extmail]# chown -R postfix:postfix cgi/
[root@mail extmail]# cp webmail.cf.default webmail.cf
[root@mail extmail]# vim webmail.cf
修改以下參數的值
SYS_CONFIG  =  /usr/local/apache/htdocs/extmail/
SYS_LANGDIR  =  /usr/local/apache/htdocs/extmail/lang
SYS_TEMPLDIR  =  /usr/local/apache/htdocs/extmail/html
SYS_MAILDIR_BASE  =  /mailbox
SYS_MYSQL_USER  =  extmail
SYS_MYSQL_PASS  =  extmail
SYS_MYSQL_DB  =  extmail
SYS_MYSQL_HOST  =  localhost
SYS_MYSQL_SOCKET  =  /tmp/mysql.sock
[root@mail extmail]# vim /usr/local/apache/conf/httpd.conf
NameVirtualHost 192.168.1.2
<VirtualHost 192.168.1.2>
    DocumentRoot /usr/local/apache/htdocs/extmail/html/
    ServerName mail.han.com
    scriptalias /extmail/cgi/ /usr/local/apache/htdocs/extmail/cgi/
    alias /extmail /usr/local/apache/htdocs/extmail/html/
    suexecusergroup postfix postfix
</VirtualHost>
重啓apache服務
[root@mail extmail]# /usr/local/apache/bin/apachectl restart
訪問測試
http://mail.han.com/extmail/cgi/
使用客戶端登陸extmail郵件系統
用戶名:postmaster
密碼:extmail
域名:extmail.org
登陸收發電子郵件進行測試!!!!
11.部署extman web管理界面
安裝perl支持軟件包GD、file-tail及rrdtool繪圖引擎工具
[root@mail tool]# tar -zxvf  GD-2.41.tar.gz
安裝GD包 安裝File-Tail包
[root@mail tool]# tar zxvf GD-2.41.tar.gz
[root@mail tool]# tar zxvf File-Tail-0.99.3.tar.gz
[root@mail tool]# cd GD-2.41
[root@mail GD-2.41]# perl Makefile.PL
[root@mail GD-2.41]# make && make install
[root@mail tool]# cd  ../File-Tail-0.99.3
[root@mail File-Tail-0.99.3]# perl Makefile.PL
[root@mail File-Tail-0.99.3]# make && make install
安裝rrdtool繪圖引擎工具rpm包安裝方式
[root@mail tool]# rpm -ivh rrdtool-1.2.23-3.el5.i386.rpm
[root@mail tool]# rpm -ivh rrdtool-perl-1.2.23-3.el5.i386.rpm
12.安裝並配置extman套件
[root@mail tool]# tar zxvf extman-0.2.5.tar.gz -C /usr/local/apache/htdocs/
[root@mail tool]# cd /usr/local/apache/htdocs
[root@mail htdocs]# mv extman-0.2.5 extman
[root@mail htdocs]# cd extman/
[root@mail extman]# chown -R postfix:postfix  /usr/local/apache/htdocs/extman/cgi
[root@mail extman]# mkdir /tmp/extman
[root@mail extman]# chown -R  postfix:postfix  /tmp/extman
[root@mail extman]# vim /usr/local/apache/htdocs/extman/webman.cf
修改參數如下:
SYS_CONFIG = /usr/local/apache/htdocs/extman/
SYS_LANGDIR = /usr/local/apache/htdocs/extman/lang
SYS_TEMPLDIR = /usr/local/apache/htdocs/extman/html
SYS_MAILDIR_BASE = /mailbox
SYS_SESS_DIR = /tmp/extman/
SYS_MYSQL_USER = webman
SYS_MYSQL_PASS = webman
SYS_MYSQL_DB = extmail
SYS_MYSQL_HOST = localhost
SYS_MYSQL_SOCKET = /tmp/mysql.sock
修改httpd.conf配置文件,添加extman的相關設置:
[root@mail extman]# vim /usr/local/apache/conf/httpd.conf
NameVirtualHost 192.168.1.2
<VirtualHost 192.168.1.2>
    DocumentRoot /usr/local/apache/htdocs/extmail/html/
    ServerName mail.han.com
    Scriptalias /extmail/cgi/ /usr/local/apache/htdocs/extmail/cgi/
    Alias /extmail /usr/local/apache/htdocs/extmail/html/
    Scriptalias /extman/cgi/ /usr/local/apache/htdocs/extman/cgi/
    Alias /extman /usr/local/apache/htdocs/extman/html/
    suexecusergroup postfix postfix
</VirtualHost>
重新啓動
/usr/local/apache/bin/apachectl restart
測試使用客戶端登陸extman管理界面
http://mail.han.com/extman/cgi/index.cgi
用戶名:[email protected]
密碼:extmail*123*
12.查看郵件系統的圖形化日誌信息
啓用 mailgraph_ext 圖形日誌插件
[root@mail ~]# ln -sf /usr/local/apache/htdocs/extman/addon/mailgraph_ext/mailgraph-init /usr/sbin/
[root@mail ~]# ln -sf /usr/local/apache/htdocs/extman/addon/mailgraph_ext/qmonitor-init /usr/sbin/
[root@mail ~]# cd /usr/local/apache/htdocs/extman/addon/mailgraph_ext/
[root@mail mailgraph_ext]# mkdir /usr/local/mailgraph_ext
[root@mail mailgraph_ext]# cp mailgraph_ext.pl qmonitor.pl /usr/local/mailgraph_ext/
[root@mail mailgraph_ext]# mailgraph-init start
[root@mail mailgraph_ext]# qmonitor-init start
[root@mail mailgraph_ext]# echo "/usr/sbin/mailgraph-init start" >> /etc/rc.d/rc.local
[root@mail mailgraph_ext]# echo "/usr/sbin/qmonitor-init start" >> /etc/rc.d/rc.local
“注意了”linux下怎麼開啓25端口
 如果出現如下錯誤(Connect to 127.0.0.1:25 fail, Net::SMTP: connect: Connection refused
)是25號端口沒有開啓
 開啓25號端口service sendmail start
13.基於郵件地址的過濾
通過配置postfix主配置文件/etc/main.cf可以實現郵件過濾的功能。
根據客戶端的主機名/地址過濾   smtpd_client_restrictions
根據HELO主機名地址過濾        smtpd_helo_required
                              smtpd_helo_restrictions
根據發件人的地址過濾          smtpd_sender_login_maps
                              smtpd_sender_restrictions
根據收件人的地址過濾          smtpd_recipient_restrictions
根據主機名/地址過濾
[root@mail ~]# vi /etc/postfix/access
……
192.168.1      REJECT
192.168.1.2    OK
jkw.net       REJECT
[root@localhost ~]# postmap  /etc/postfix/access
[root@mail ~]# vi /etc/postfix/main.cf
smtpd_client_restrictions = check_client_access hash:/etc/postfix/access
示例測試需要的虛擬域、虛擬郵件用戶、客戶端需要自己創建,並測試過濾是否有效。
根據HELO宣告的地址過濾
[root@mail ~]# vi /etc/postfix/main.cf
……
smtpd_helo_required = yes
smtpd_helo_restrictions =  reject_invalid_hostname

應用示例3:根據發件人地址過濾
[root@mail ~]# vi /etc/postfix/main.cf
smtpd_sender_login_maps =
  mysql:/etc/postfix/mysql_virtual_sender_maps.cf,
  mysql:/etc/postfix/mysql_virtual_alias_maps.cf
smtpd_sender_restrictions =permit_mynetworks,reject_sender_login_mismatch, reject_non_fqdn_sender, reject_unknown_sender_domain,
  check_sender_access hash:/etc/postfix/sender_access

[root@mail ~]# vi /etc/postfix/sender_access
……
[email protected]??????????REJECT
marketing@???????????REJECT
fake.jkw.net   ???????   REJECT
[root@mail ~]# postmap /etc/postfix/sender_access
應用示例4:根據收件人地址過濾
[root@mail ~]# vi /etc/postfix/main.cf
smtpd_recipient_restrictions =
  permit_mynetworks,                     //允許本郵件系統發出的郵件
  permit_sasl_authenticated,             //允許通過sasl認證的用戶作爲發件人
  reject_unauth_destination,             //收件人地址域不包括在Postfix授權網絡內時拒絕
  reject_non_fqdn_recipient,             //收件人地址域不屬於合法FQDN時拒絕
  reject_unknown_recipient_domain        //收件人地址域未知或不存在時拒絕
郵件內容過濾及防病毒
安裝MailScanner調度工具
[root@www mail]# tar zxvf MailScanner-4.75.11-1.rpm.tar.gz
[root@www mail]# cd MailScanner-4.75.11-1
[root@www MailScanner-4.75.11-1]# ./install.sh
說明:
mailscanner的安裝會提示需要安裝多個perl軟件包,可以掛載光盤查找安裝即可!
需要大概25分鐘時間,較長,需要耐心!
修改配置文件/etc/MailScanner/MailScanner.conf
[root@mail ~]# vi /etc/MailScanner/MailScanner.conf          
Run As User = postfix                         
Run As Group = postfix
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
MTA = postfix
Required SpamAssassin Score = 7
High SpamAssassin Score = 10
Spam Actions = deliver header "X-Spam-Status: Yes"
High Scoring Spam Actions = delete forward [email protected]
3、配置postfix支持調用MailScanner
[root@mail ~]# vi /etc/postfix/main.cf
header_checks = regexp:/etc/postfix/header_checks
4、調整過濾隊列目錄,啓動MailScanner服務
[root@mail ~]# vi /etc/postfix/header_checks
/^Received:/  HOLD
[root@mail ~]# cd /var/spool/MailScanner/
[root@mail MailScanner]# chown -R postfix.postfix  incoming
[root@mail MailScanner]# chown -R postfix.postfix quarantine
[root@mail MailScanner]# service MailScanner start
5、安裝 SpamAssassin 過濾器
從RHEL5光盤中查找安裝即可,包括存在依賴關係的相關perl軟件包
啓動 spamassassin 服務
 service spamassassin start
6、安裝 F-Prot 病毒掃描工具
[root@www mail]# tar zxvf fp-Linux-i686-ws.tar.gz
[root@www mail]# cd f-prot/
[root@www f-prot]# ./install-f-prot.pl
7、按照書上給出的測試方法進行郵件內容過濾和防病毒機制的測試!

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章