Mail系统搭建
系统环境:rhel6.0-x86-64 selinux and iptables off
主机:192.168.0.3
yum install mysql-server
/etc/init.d/mysqld start
postconf -m #查看 postfix是否支持mysql
....
mysql
....
####create database postfix, create tables student
username test@westos.org
password 123456
domain westos.org
mailbox westos.org/test/
postconf -e inet_interfaces=all
[root@server2 ~]# ls -l /usr/sbin/sendmail
lrwxrwxrwx. 1 root root 21 Oct 18 18:59 /usr/sbin/sendmail -> /etc/alternatives/mta
[root@server2 ~]# ls -l /etc/alternatives/mta
lrwxrwxrwx. 1 root root 26 Oct 18 18:59 /etc/alternatives/mta -> /usr/sbin/sendmail.postfix
[root@server2 ~]# ls -l //usr/sbin/sendmail.postfix
-rwxr-xr-x. 1 root root 213616 Mar 10 2011 //usr/sbin/sendmail.postfix
useradd -u 600 vmail
[root@server2 ~]# postconf -e virtual_uid_maps=static:600
[root@server2 ~]# postconf -e virtual_gid_maps=static:600
[root@server2 ~]# postconf -e virtual_mailbox_base=/home/vmail/
[root@server2 ~]# postconf -e virtual_alias_maps=mysql:/etc/postfix/mysql-alias.cf
[root@server2 ~]# postconf -e virtual_mailbox_domains=mysql:/etc/postfix/mysql-domains.cf
[root@server2 ~]# postconf -e virtual_mailbox_maps=mysql:/etc/postfix/mysql-mailboxs.cf
#授权于 vmail用户
mysql> grant all on postfix.* to vmail@localhost identified by 'vmail';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
vim /etc/postfix/mysql-alias.cf
user = vmail
password = vmail
dbname = postfix
table = student
select_field = username
where_field = usernam
vim /etc/postfix/mysql-domains.cf
user = vmail
password = vmail
dbname = postfix
table = student
select_field = domain
where_field = domain
vim /etc/postfix/mysql-mailboxs.cf
user = vmail
password = vmail
dbname = postfix
table = student
select_field = mailbox
where_field = usernam
[root@server3 postfix]# postmap -q "test@westos.org" mysql:/etc/postfix/mysql-alias.cf
test@westos.org
[root@server3 postfix]# postmap -q "test@westos.org" mysql:/etc/postfix/mysql-mailboxs.cf
westos.org/test/
[root@server3 postfix]# postmap -q "westos.org" mysql:/etc/postfix/mysql-domains.cf
westos.org
/etc/init.d/postfix restart
#发送测试邮件
[root@server3 postfix]# mail test@westos.org
Subject: test
test
test
test
EOT
#切到如下目录查收邮件
#cd /home/vmail/westos.org/test/new
[root@server3 new]# ls
1322315156.Vfd02I8014M798586.server3
[root@server3 new]# cat 1322315156.Vfd02I8014M798586.server3
Return-Path:
X-Original-To: test@westos.org
Delivered-To: test@westos.org
Received: by server3.localdomain (Postfix, from userid 0)
id 019338CA0; Sat, 26 Nov 2011 21:40:09 +0800 (CST)
Date: Sat, 26 Nov 2011 21:40:09 +0800
To: test@westos.org
Subject: test
User-Agent: Heirloom mailx 12.4 7/29/08
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-Id: <20111126134010.019338CA0@server3.localdomain>
From: root@server3.localdomain (root)
test
test
test
----------------------------------
#安装 dovecot 客户端
yum install dovecot dovecot-mysql -y
#编辑文件
vim /etc/dovecot/conf.d/10-mail.conf
....
#
mail_location = maildir:/home/vmail/%d/%n
....
first_valid_uid = 600
#last_valid_uid = 0
....
vim /etc/dovecot/conf.d/10-auth.conf
....
!include auth-sql.conf.ext #去掉此句的注释
....
#切到如下目录,并拷贝文件到指定目录
cd /usr/share/doc/dovecot-2.0/example-config
[root@server3 example-config]# cp dovecot-sql.conf.ext /etc/dovecot/
#编辑拷贝的文件
vim /etc/dovecot/dovecot-sql.conf.ext
....
driver = mysql
....
# Examples:
# connect = host=192.168.1.1 dbname=users
connect = host=localhost dbname=postfix user=vmail password=vmail
# connect = /etc/dovecot/authdb.sqlite
....
default_pass_scheme = PLAIN
....
# Example:
# password_query = SELECT userid AS user, pw AS password \
# FROM users WHERE userid = '%u' AND active = 'Y'
password_query = \
SELECT username, domain, password \
FROM student WHERE username = '%u'
....
# Examples:
# user_query = SELECT home, uid, gid FROM users WHERE userid = '%u'
# user_query = SELECT dir AS home, user AS uid, group AS gid FROM users where userid = '%u'
user_query = SELECT mailbox, 600 AS uid, 600 AS gid FROM student WHERE username = '%u'
#开启 dovecot服务
/etc/init.d/dovecot start
#查看 dovecot的端口
netstat -antlp
tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 3384/dovecot
tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 3384/dovecot
....
tcp 0 0 0.0.0.0:993 0.0.0.0:* LISTEN 3384/dovecot
tcp 0 0 0.0.0.0:995 0.0.0.0:* LISTEN 3384/dovecot
#安装 telnet测试
yum install telnet -y
[root@server3 dovecot]# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
user test@westos.org
+OK
pass 123456
+OK Logged in.
list
+OK 1 messages:
1 548
.
quit
+OK Logging out.
Connection closed by foreign host.
-------------------------------------------------------
#配置web邮件服务器 extmail
软件: extmail-1.2.tar.gz extman-1.1.tar.gz
[root@server3 mnt]# mkdir /var/www/extsuite
[root@server3 mnt]# tar -zxf extmail-1.2.tar.gz -C /var/www/extsuite/
[root@server3 mnt]# tar -zxf extman-1.1.tar.gz -C /var/www/extsuite/
#切到/var/www/extsuite ,为方便给解压后的目录改名字
cd /var/www/extsuite
[root@server3 extsuite]# mv extmail-1.2/ extmail
[root@server3 extsuite]# mv extman-1.1/ extman
[root@server3 extmail]# cd extman/docs/
[root@server3 docs]# mysql < extmail.sql
[root@server3 docs]# vim init.sql
...
('postmaster@extmail.org','postmaster','redhat','','PostMaster','','extmail.org/postmaster/Maildir/','extma
il.org/postmaster','104857600S','52428800S','extmail.org',1000,1000,'2007-02-14 15:10:04','2010-11-
08',1,0,0,0,0,0,0,0,'my question','my answer');
....
INSERT INTO `manager` VALUES ('root@extmail.org','westos','admin','root','Super User','my
question','my answer','0','2007-02-14 15:10:04','2010-11-08',1);
....
[root@server3 docs]# mysql < init.sql
[root@server3 docs]# cat mysql_virtual_alias_maps.cf
user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = alias
select_field = goto
where_field = address
additional_conditions = AND active = '1'
[root@server3 docs]# cat mysql_virtual_domains_maps.cf
user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = domain
select_field = domain
where_field = domain
additional_conditions = AND active = '1'
[root@server3 docs]# cat mysql_virtual_mailbox_maps.cf
user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = mailbox
select_field = maildir
where_field = username
additional_conditions = AND active = '1'
[root@server3 docs]# cp mysql_virtual_alias_maps.cf /etc/postfix/mysql-alias.cf
[root@server3 docs]# cp mysql_virtual_domains_maps.cf /etc/postfix/mysql-domains.cf
[root@server3 docs]# cp mysql_virtual_mailbox_maps.cf /etc/postfix/mysql-mailboxs.cf
[root@server3 docs]# postmap -q "support@extmail.org" mysql:/etc/postfix/mysql-alias.cf
postmaster@extmail.org
[root@server3 docs]# postmap -q "postmaster@extmail.org" mysql:/etc/postfix/mysql-mailboxs.cf
extmail.org/postmaster/Maildir/
[root@server3 docs]# postmap -q "extmail.org" mysql:/etc/postfix/mysql-domains.cf
extmail.org
#测试
[root@server3 docs]# mail support@extmail.org
Subject: xili
xili
xili
xili
EOT
#切到目录/home/vmail/extmail.org/postmaster/Maildir/new
[root@server3 new]# ls
1322323967.Vfd02I801fM829896.server3
[root@server3 new]# cat 1322323967.Vfd02I801fM829896.server3
Return-Path:
X-Original-To: support@extmail.org
Delivered-To: postmaster@extmail.org
Received: by server3.localdomain (Postfix, from userid 0)
id AD5856B7E; Sun, 27 Nov 2011 00:12:47 +0800 (CST)
Date: Sun, 27 Nov 2011 00:12:47 +0800
To: support@extmail.org
Subject: xili
User-Agent: Heirloom mailx 12.4 7/29/08
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-Id: <20111126161247.AD5856B7E@server3.localdomain>
From: root@server3.localdomain (root)
xili
xili
xili
#编辑文件
vim /etc/dovecot/conf.d/10-mail.conf
....
#mail_location = maildir:/home/vmail/%d/%n
mail_location = maildir:/home/vmail/%d/%n/Maildir
....
vim /etc/dovecot/dovecot-sql.conf.ext
....
# Examples:
#connect = host=192.168.1.1 dbname=users
connect = host=localhost dbname=extmail user=extmail password=extmail
....
# Example:
#password_query = SELECT userid AS user, pw AS password \
#FROM users WHERE userid = '%u' AND active = 'Y'
#
password_query = \
SELECT username, domain, password \
FROM mailbox WHERE username = '%u'
....
# Examples:
# user_query = SELECT home, uid, gid FROM users WHERE userid = '%u'
# user_query = SELECT dir AS home, user AS uid, group AS gid FROM users where userid = '%u'
user_query=SELECT maildir, 600 AS uid, 600 AS gid FROM mailbox WHERE username = '%u'
....
[root@server3 extman]# chown vmail.vmail cgi/ -R
[root@server3 extman]# vim webman.cf
....
# maildir_base, the base dir of user maildir, use absolute path
# if not set.
SYS_MAILDIR_BASE = /home/vmail
....
# sys_sess_dir, the session dir
SYS_SESS_DIR = /tmp
# sys_captcha_on 1|0 - to enable captcha feature or not
SYS_CAPTCHA_ON = 0
....
# sys_crypt_type: crypt|cleartext|plain|md5|md5crypt|plain-md5|ldap-md5|sha|sha1
SYS_CRYPT_TYPE = plain
....
#编辑 apache的主配置文件添加如下语句
vim /etc/httpd/conf/httpd.conf
....
NameVirtualHost *:80
ServerName mail.extmail.org
DocumentRoot /var/www/extsuite/extmail/html/
ScriptAlias /extmail/cgi /var/www/extsuite/extmail/cgi
Alias /extmail /var/www/extsuite/extmail/html
ScriptAlias /extman/cgi /var/www/extsuite/extman/cgi
Alias /extman /var/www/extsuite/extman/html
SuexecUserGroup vmail vmail
vim /etc/hosts
192.168.0.3 mail.extmail.org
[root@server3 extman]# yum install perl-CGI -y
[root@server3 extsuite]# cd extmail/
[root@server3 extmail]# chown vmail.vmail cgi/ -R
[root@server3 extmail]# cp webmail.cf.default webmail.cf
[root@server3 extmail]# vim webmail.cf
....
# sys_log_on = 1 | 0 - enable logging or not
SYS_LOG_ON = 0
....
# maildir_base, the base dir of user maildir, use absolute path
# if not set.
SYS_MAILDIR_BASE = /home/vmail
....
# crypt_type, the default encrypt type of password, possible type
# currently is crypt|cleartext|plain|md5|md5crypt|plain-md5|ldap-md5|sha|sha1
SYS_CRYPT_TYPE = plain
# if mysql, all relate parameters should prefix as SYS_MYSQL
SYS_MYSQL_USER = extmail
SYS_MYSQL_PASS = extmail
....
----------------------------------------------------
#关于邮件日志的管理
vim /var/www/extsuite/extmail/webmail.cf
....
# sys_log_on = 1 | 0 - enable logging or not
SYS_LOG_ON = 1
# sys_log_type = file|syslog|nsyslog, syslog will save login
# or error info into mail.*, nsyslog is a replacement to syslog
# that will send log message to network syslogd
SYS_LOG_TYPE = syslog
# sys_log_file - path to log file, if sys_log_type = file
SYS_LOG_FILE = /var/log/extmail.log
....
[root@server3 ~]# tar -zxf Unix-Syslog-1.1.tar.gz
[root@server3 ~]# cd Unix-Syslog-1.1
[root@server3 Unix-Syslog-1.1]# ls
Artistic Makefile.PL META.yml Syslog.pm test.pl
Changes MANIFEST README Syslog.xs
[root@server3 Unix-Syslog-1.1]# perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for Unix::Syslog
[root@server3 Unix-Syslog-1.1]# make test
[root@server3 Unix-Syslog-1.1]# make install
#验证码设置
vim /var/www/extsuite/extman/webman.cf
....
# sys_captcha_on 1|0 - to enable captcha feature or not
SYS_CAPTCHA_ON = 1
# sys_captcha_key
SYS_CAPTCHA_KEY = r3s9b6a7
# sys_captcha_len
SYS_CAPTCHA_LEN = 6
....
[root@server3 extman]# yum install perl-GD -y
[root@server3 extman]# rpm -q perl-rrdtool
[root@server3 addon]# cp -r mailgraph_ext/ /usr/local/
[root@server3 addon]# cd /usr/local/
[root@server3 ~]# tar -zxf File-Tail-0.99.3.tar.gz
[root@server3 ~]# cd File-Tail-0.99.3
[root@server3 File-Tail-0.99.3]# perl Makefile.PL
File::Tail will be installed without debugging information.
This information isn't usefull unless you intend to tinker
with the code. To install with debugging enabled, use:
perl Makefile.PL LOGIT
Checking if your kit is complete...
Looks good
Writing Makefile for File::Tail
[root@server3 File-Tail-0.99.3]# make test
[root@server3 File-Tail-0.99.3]# make install
[root@server3 mailgraph_ext]# ./mailgraph-init start
Starting mail statistics grapher: mailgraph_ext
Starting queue statistics grapher: qmonitor
本文档为【mail系统哦_xili】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。