共计 15549 个字符,预计需要花费 39 分钟才能阅读完成。
服务器数据库
[root@localhost ~]# yum install mysql-server -y
[root@localhost ~]# /etc/init.d/mysqld start
[root@localhost ~]# mysql_secure_installation 设置密码为 westos
[root@localhost ~]# yum install httpd -y
[root@localhost ~]# lftp 192.168.0.1
lftp 192.168.0.1:/pub/postfix> get extmail-1.2.tar.gz extman-1.1.tar.gz
[root@localhost ~]# tar zxf extman-1.1.tar.gz
[root@localhost ~]# tar zxf extmail-1.2.tar.gz
[root@localhost ~]# cd extman-1.1/docs/
[root@localhost docs]# mysql -pwestos < extmail.sql
[root@localhost docs]# vim init.sql
INSERT INTO `mailbox` VALUES (‘postmaster@extmail.org’,’postmaster’,’westos’,”,’PostMaster’,”,’extmail.org/postmaster/Maildir/’,’extmail.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@localhost docs]# mysql -pwestos < init.sql
[root@localhost docs]# useradd -u 800 vmail
[root@localhost docs]# postconf -e virtual_mailbox_base=/home/vmail/
[root@localhost docs]# postconf -e virtual_uid_maps=static:800
[root@localhost docs]# postconf -e virtual_gid_maps=static:800
[root@localhost docs]# cp mysql_virtual_alias_maps.cf mysql_virtual_domains_maps.cf mysql_virtual_mailbox_maps.cf /etc/postfix/
[root@localhost postfix]# postconf -e virtual_alias_maps=mysql:/etc/postfix/mysql_virtual_alias_maps.cf
[root@localhost postfix]# postconf -e virtual_mailbox_domains=mysql:/etc/postfix/mysql_virtual_domains_maps.cf
[root@localhost postfix]# postconf -e virtual_mailbox_maps=mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
[root@localhost postfix]# postfix reload
[root@localhost postfix]# yum install mailx-12.4-6.el6.x86_64 -y
[root@localhost postfix]# mail support@extmail.org
Subject: test
qwertyuiop
asdfghjkl
EOT
[root@localhost postfix]# mailq
Mail queue is empty
这时候,在 /home/vmail/extmail.org/postmaster/Maildir/new 下会有一封新的邮件
3 月 30 日 第二天从这里开始
[root@localhost docs]# mkdir /var/www/extsuite
[root@localhost ~]# mv extman-1.1 /var/www/extsuite/extman
[root@localhost ~]# mv extmail-1.2 /var/www/extsuite/extmail
[root@localhost ~]# cd /var/www/extsuite/
[root@localhost extsuite]# chown vmail.vmail * -R
[root@localhost extsuite]# cp extmail/webmail.cf.default extmail/webmail.cf
[root@localhost extsuite]# cp extman/webman.cf.default extman/webman.cf
/etc/httpd/conf/httpd.conf 加入
NameVirtualHost *:80
<VirtualHost *: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
</VirtualHost>
主机名修改为 mail.extmail.org
[root@localhost extsuite]# /etc/init.d/httpd restart
[root@localhost extsuite]# vi extmail/webmail.cf
修改配置文件 extmail/webmail.cf
SYS_LOG_ON = 0
SYS_MAILDIR_BASE = /home/vmail
SYS_CRYPT_TYPE = plain
SYS_MYSQL_USER = extmail
SYS_MYSQL_PASS = extmail
修改配置文件 extman/webman.cf
SYS_CAPTCHA_ON = 0
SYS_MAILDIR_BASE = /home/vmail
SYS_SESS_DIR = /tmp/
SYS_CRYPT_TYPE = plain
SYS_MYSQL_USER = webman
SYS_MYSQL_PASS = webman
[root@localhost extsuite]# yum install perl-CGI -y
客户端 192.168.0.1 做 192.168.0.146 mail.extmail.org 解析
访问 mail.extmail.org 用户 uname:postmaster passwd:westos
http://mail.extmail.org/extman/cgi/index.cgi 管理员 passwd:westos
后台运行,管理员可查看系统信息
[root@localhost extsuite]# /var/www/extsuite/extman/daemon/cmdserver &
接下来添加功能
1. 打开 LOG 功能记录登录状况
修改配置文件 extmail/webmail.cf
SYS_LOG_ON = 1
[root@localhost ~]# tar zxf Unix-Syslog-1.1.tar.gz
[root@localhost Unix-Syslog-1.1]# perl Makefile.PL
Can’t locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 1.
BEGIN failed–compilation aborted at Makefile.PL line 1.
[root@localhost Unix-Syslog-1.1]# yum install -y perl-ExtUtils-MakeMaker
[root@localhost Unix-Syslog-1.1]# yum install make gcc -y
[root@localhost Unix-Syslog-1.1]# perl Makefile.PL
[root@localhost Unix-Syslog-1.1]# make install
[root@localhost ~]# tail -f /var/log/maillog 查看日志
2. 加入验证码防暴力注册
修改配置文件 extman/webman.cf
SYS_CAPTCHA_ON = 1
[root@localhost ~]# yum localinstall perl-GD-2.45-1.el6.rfx.x86_64.rpm -y
3. 绘制图表查看登录频率等信息
[root@localhost ~]# yum install rrdtool-perl-1.3.8-6.el6.x86_64.rpm -y
[root@localhost ~]# cp -r /var/www/extsuite/extman/addon/mailgraph_ext/ /usr/local/
lftp 192.168.0.1:~> get pub/postfix/File-Tail-0.99.3.tar.gz
[root@localhost ~]# tar zxf File-Tail-0.99.3.tar.gz
[root@localhost ~]# cd File-Tail-0.99.3
[root@localhost File-Tail-0.99.3]# yum install perl-Time-HiRes -y
[root@localhost File-Tail-0.99.3]# perl Makefile.PL
[root@localhost File-Tail-0.99.3]# make install
[root@localhost File-Tail-0.99.3]# /usr/local/mailgraph_ext/mailgraph-init start
刷新管理员页面,点击 Graph Log
使用 dovecot 接收邮件
[root@mail ~]# yum install dovecot-mysql -y
[root@mail conf.d]# vim 10-mail.conf
mail_location = maildir:/home/vmail/%d/%n/Maildir
first_valid_uid = 800
[root@mail conf.d]# vim 10-auth.conf
#!include auth-system.conf.ext
!include auth-sql.conf.ext
[root@mail conf.d]# cp /usr/share/doc/dovecot-2.0.9/example-config/dovecot-sql.conf.ext /etc/dovecot/
[root@mail dovecot]# vim dovecot-sql.conf.ext
driver = mysql
connect = host=localhost dbname=extmail user=extmail password=extmail
default_pass_scheme = PLAIN
password_query = \
SELECT username, domain, password \
FROM mailbox WHERE username = ‘%u’ AND domain = ‘%d’
user_query = SELECT maildir, 800 AS uid, 800 AS gid FROM mailbox WHERE username = ‘%u’
[root@mail dovecot]# /etc/init.d/dovecot restart
[root@mail ~]# yum install telnet* -y
[root@mail dovecot]# telnet localhost 110
Trying ::1…
Connected to localhost.
Escape character is ‘^]’.
+OK Dovecot ready.
user weifang@extmail.org
+OK
pass weifang
+OK Logged in.
list
+OK 0 messages:
.
相关阅读:
CentOS 6.4 下 Postfix 邮件服务安装和基本配置 http://www.linuxidc.com/Linux/2013-08/88977.htm
CentOS 5.5 下邮件服务器 Postfix 安装 http://www.linuxidc.com/Linux/2012-05/60010.htm
搭建 Red Hat Enterprise Linux 5.4 的 Postfix 邮件服务器 http://www.linuxidc.com/Linux/2012-12/77167.htm
Linux 下架构安全邮件服务器之 Postfix(认证)http://www.linuxidc.com/Linux/2012-09/70527.htm
使用雷鸟客户端
在客户端安装 thunderbird-17.0.2-1.el6.remi.x86_64
设置账户就好了
服务器
[root@mail ~]# vim /etc/postfix/main.cf
inet_interfaces = all
为使功能健全,在 /etc/rc.local 添加
[root@localhost File-Tail-0.99.3]# vi /etc/rc.local
/var/www/extsuite/extman/daemon/cmdserver &
/usr/local/mailgraph_ext/mailgraph-init start
[root@localhost ~]# chkconfig httpd on
[root@localhost ~]# chkconfig mysqld on
[root@mail ~]# chkconfig dovecot on
第二个周
1、postfix 升级
[root@mail postfix-2.11.0]# /etc/init.d/postfix stop
[root@mail postfix-2.11.0]# yum install -y cyrus-sasl-*
[root@mail postfix-2.11.0]# yum install openssl-devel.x86_64 -y
[root@mail postfix-2.11.0]# yum install mysql-devel.x86_64 -y
[root@mail postfix-2.11.0]# yum install db4-devel-4.7.25-17.el6.x86_64 -y
[root@mail postfix-2.11.0]# make tidy
[root@mail postfix-2.11.0]# make -f Makefile.init makefiles ‘CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS’ ‘AUXLIBS=-L/usr/lib64/mysql/ -lmysqlclient -lz -lm -L/usr/lib64 -lsasl2 -lssl -lcrypto’
[root@mail postfix-2.11.0]# make upgrade
[root@mail ~]# postconf mail_version
mail_version = 2.11.0 查看版本
[root@mail certs]# postconf -A
cyrus
[root@mail certs]# postconf -a
cyrus
dovecot
带上 mysql
[root@mail certs]# postconf -m
2、发信身份验证,使用统一密码
[root@mail ~]# yum localinstall -y cyrus-sasl-sql-2.1.23-13.el6.x86_64.rpm 注意版本
yum localinstall cyrus-sasl-sql-2.1.23-13.el6_3.1.x86_64.rpm
[root@mail sasl2]# vim /etc/sasl2/smtpd.conf
pwcheck_method: auxprop
auxprop_plugin: sql
mech_list: PLAIN LOGIN CRAM-MD5 DIGEST-MD5 NTLM
sql_engine: mysql
sql_hostnames: 127.0.0.1
sql_user: extmail
sql_passwd: extmail
sql_database: extmail
sql_select: SELECT password FROM mailbox WHERE username = ‘%u@%r’
[root@mail sasl2]# postconf -e smtpd_sasl_auth_enable=yes
[root@mail sasl2]# postfix reload
[root@mail sasl2]# perl -MMIME::Base64 -e ‘print encode_base64(“\0weifang\@extmail.org\0weifang”);’
AHdlaWZhbmdAZXh0bWFpbC5vcmcAd2VpZmFuZw==
[root@mail sasl2]# telnet localhost 25
ehlo mail.extmail.org
auth plain AHdlaWZhbmdAZXh0bWFpbC5vcmcAd2VpZmFuZw==
使用雷鸟 outgoing server
编辑
connection none
authentication password,transmitted insecurely
username weifang@extmail.org
之后,用户 weifang@extmail.org 发送邮件就会进行身份验证
登录需要身份验证,发信也需要验证身份,防止身份伪造或者非邮箱本人发信
3、加密发送
[root@mail sasl2]# postconf -e smtpd_tls_auth_only=yes
[root@mail sasl2]# postfix reload
[root@mail sasl2]# telnet localhost 25
ehlo localhost
没有这个 250-AUTH LOGIN CRAM-MD5 DIGEST-MD5 PLAIN
改成 no,就会有 250-AUTH LOGIN CRAM-MD5 DIGEST-MD5 PLAIN
[root@mail certs]# postconf -e smtpd_tls_auth_only=no
[root@mail sasl2]# postconf -e smtpd_tls_security_level=may 可以不加密发送
就会多一条这个,表示开启 TLS 加密
250-STARTTLS
生成加密验证文件
[root@mail sasl2]# cd /etc/pki/tls/certs/
[root@mail certs]# make postfix.pem
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:shaanxi
Locality Name (eg, city) [Default City]:xi’an
Organization Name (eg, company) [Default Company Ltd]:westos
Organizational Unit Name (eg, section) []:LINUX
Common Name (eg, your name or your server’s hostname) []:mail.extmail.org
Email Address []:root@example.com
[root@mail certs]# cp postfix.pem /etc/postfix/
[root@mail certs]# postconf -d | grep ^smtpd_tls
[root@mail certs]# postconf -e smtpd_tls_cert_file=/etc/postfix/postfix.pem
[root@mail certs]# postconf -e ‘smtpd_tls_session_cache_database = btree:/var/lib/postfix/smtpd_scache’
[root@mail certs]# postconf - n 加上这四条
smtpd_tls_auth_only = no
smtpd_tls_cert_file = /etc/postfix/postfix.pem
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:/var/lib/postfix/smtpd_scache
这时,雷鸟设置 outgoing 为
连接加密 connection STARTTLS 使用加密或者 none 不使用加密都可以正常发送
认证方法 authentication normal password
用户信息 username weifang@extmail.org
weifang 发送邮件的话,需要确认网络环境安全,并得到验证文件,可以发送
修改为强制加密
[root@mail certs]# postconf -e smtpd_tls_security_level=encrypt
[root@mail certs]# postconf -e smtpd_tls_auth_only=yes
[root@mail certs]# postfix reload
如果不使用加密,就不能发送,这样就保证了安全
连接加密 connection STARTTLS 使用加密
认证方法 authentication normal password
用户信息 username weifang@extmail.org
服务器数据库
[root@localhost ~]# yum install mysql-server -y
[root@localhost ~]# /etc/init.d/mysqld start
[root@localhost ~]# mysql_secure_installation 设置密码为 westos
[root@localhost ~]# yum install httpd -y
[root@localhost ~]# lftp 192.168.0.1
lftp 192.168.0.1:/pub/postfix> get extmail-1.2.tar.gz extman-1.1.tar.gz
[root@localhost ~]# tar zxf extman-1.1.tar.gz
[root@localhost ~]# tar zxf extmail-1.2.tar.gz
[root@localhost ~]# cd extman-1.1/docs/
[root@localhost docs]# mysql -pwestos < extmail.sql
[root@localhost docs]# vim init.sql
INSERT INTO `mailbox` VALUES (‘postmaster@extmail.org’,’postmaster’,’westos’,”,’PostMaster’,”,’extmail.org/postmaster/Maildir/’,’extmail.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@localhost docs]# mysql -pwestos < init.sql
[root@localhost docs]# useradd -u 800 vmail
[root@localhost docs]# postconf -e virtual_mailbox_base=/home/vmail/
[root@localhost docs]# postconf -e virtual_uid_maps=static:800
[root@localhost docs]# postconf -e virtual_gid_maps=static:800
[root@localhost docs]# cp mysql_virtual_alias_maps.cf mysql_virtual_domains_maps.cf mysql_virtual_mailbox_maps.cf /etc/postfix/
[root@localhost postfix]# postconf -e virtual_alias_maps=mysql:/etc/postfix/mysql_virtual_alias_maps.cf
[root@localhost postfix]# postconf -e virtual_mailbox_domains=mysql:/etc/postfix/mysql_virtual_domains_maps.cf
[root@localhost postfix]# postconf -e virtual_mailbox_maps=mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
[root@localhost postfix]# postfix reload
[root@localhost postfix]# yum install mailx-12.4-6.el6.x86_64 -y
[root@localhost postfix]# mail support@extmail.org
Subject: test
qwertyuiop
asdfghjkl
EOT
[root@localhost postfix]# mailq
Mail queue is empty
这时候,在 /home/vmail/extmail.org/postmaster/Maildir/new 下会有一封新的邮件
3 月 30 日 第二天从这里开始
[root@localhost docs]# mkdir /var/www/extsuite
[root@localhost ~]# mv extman-1.1 /var/www/extsuite/extman
[root@localhost ~]# mv extmail-1.2 /var/www/extsuite/extmail
[root@localhost ~]# cd /var/www/extsuite/
[root@localhost extsuite]# chown vmail.vmail * -R
[root@localhost extsuite]# cp extmail/webmail.cf.default extmail/webmail.cf
[root@localhost extsuite]# cp extman/webman.cf.default extman/webman.cf
/etc/httpd/conf/httpd.conf 加入
NameVirtualHost *:80
<VirtualHost *: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
</VirtualHost>
主机名修改为 mail.extmail.org
[root@localhost extsuite]# /etc/init.d/httpd restart
[root@localhost extsuite]# vi extmail/webmail.cf
修改配置文件 extmail/webmail.cf
SYS_LOG_ON = 0
SYS_MAILDIR_BASE = /home/vmail
SYS_CRYPT_TYPE = plain
SYS_MYSQL_USER = extmail
SYS_MYSQL_PASS = extmail
修改配置文件 extman/webman.cf
SYS_CAPTCHA_ON = 0
SYS_MAILDIR_BASE = /home/vmail
SYS_SESS_DIR = /tmp/
SYS_CRYPT_TYPE = plain
SYS_MYSQL_USER = webman
SYS_MYSQL_PASS = webman
[root@localhost extsuite]# yum install perl-CGI -y
客户端 192.168.0.1 做 192.168.0.146 mail.extmail.org 解析
访问 mail.extmail.org 用户 uname:postmaster passwd:westos
http://mail.extmail.org/extman/cgi/index.cgi 管理员 passwd:westos
后台运行,管理员可查看系统信息
[root@localhost extsuite]# /var/www/extsuite/extman/daemon/cmdserver &
接下来添加功能
1. 打开 LOG 功能记录登录状况
修改配置文件 extmail/webmail.cf
SYS_LOG_ON = 1
[root@localhost ~]# tar zxf Unix-Syslog-1.1.tar.gz
[root@localhost Unix-Syslog-1.1]# perl Makefile.PL
Can’t locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 1.
BEGIN failed–compilation aborted at Makefile.PL line 1.
[root@localhost Unix-Syslog-1.1]# yum install -y perl-ExtUtils-MakeMaker
[root@localhost Unix-Syslog-1.1]# yum install make gcc -y
[root@localhost Unix-Syslog-1.1]# perl Makefile.PL
[root@localhost Unix-Syslog-1.1]# make install
[root@localhost ~]# tail -f /var/log/maillog 查看日志
2. 加入验证码防暴力注册
修改配置文件 extman/webman.cf
SYS_CAPTCHA_ON = 1
[root@localhost ~]# yum localinstall perl-GD-2.45-1.el6.rfx.x86_64.rpm -y
3. 绘制图表查看登录频率等信息
[root@localhost ~]# yum install rrdtool-perl-1.3.8-6.el6.x86_64.rpm -y
[root@localhost ~]# cp -r /var/www/extsuite/extman/addon/mailgraph_ext/ /usr/local/
lftp 192.168.0.1:~> get pub/postfix/File-Tail-0.99.3.tar.gz
[root@localhost ~]# tar zxf File-Tail-0.99.3.tar.gz
[root@localhost ~]# cd File-Tail-0.99.3
[root@localhost File-Tail-0.99.3]# yum install perl-Time-HiRes -y
[root@localhost File-Tail-0.99.3]# perl Makefile.PL
[root@localhost File-Tail-0.99.3]# make install
[root@localhost File-Tail-0.99.3]# /usr/local/mailgraph_ext/mailgraph-init start
刷新管理员页面,点击 Graph Log
使用 dovecot 接收邮件
[root@mail ~]# yum install dovecot-mysql -y
[root@mail conf.d]# vim 10-mail.conf
mail_location = maildir:/home/vmail/%d/%n/Maildir
first_valid_uid = 800
[root@mail conf.d]# vim 10-auth.conf
#!include auth-system.conf.ext
!include auth-sql.conf.ext
[root@mail conf.d]# cp /usr/share/doc/dovecot-2.0.9/example-config/dovecot-sql.conf.ext /etc/dovecot/
[root@mail dovecot]# vim dovecot-sql.conf.ext
driver = mysql
connect = host=localhost dbname=extmail user=extmail password=extmail
default_pass_scheme = PLAIN
password_query = \
SELECT username, domain, password \
FROM mailbox WHERE username = ‘%u’ AND domain = ‘%d’
user_query = SELECT maildir, 800 AS uid, 800 AS gid FROM mailbox WHERE username = ‘%u’
[root@mail dovecot]# /etc/init.d/dovecot restart
[root@mail ~]# yum install telnet* -y
[root@mail dovecot]# telnet localhost 110
Trying ::1…
Connected to localhost.
Escape character is ‘^]’.
+OK Dovecot ready.
user weifang@extmail.org
+OK
pass weifang
+OK Logged in.
list
+OK 0 messages:
.
相关阅读:
CentOS 6.4 下 Postfix 邮件服务安装和基本配置 http://www.linuxidc.com/Linux/2013-08/88977.htm
CentOS 5.5 下邮件服务器 Postfix 安装 http://www.linuxidc.com/Linux/2012-05/60010.htm
搭建 Red Hat Enterprise Linux 5.4 的 Postfix 邮件服务器 http://www.linuxidc.com/Linux/2012-12/77167.htm
Linux 下架构安全邮件服务器之 Postfix(认证)http://www.linuxidc.com/Linux/2012-09/70527.htm