在RHEL5.3上安装基于postfix的extmail邮件系统
extmail官方网站上的安装指南是针对4.x系统的,网上找了一个5.x的安装。
参考在centos/redhat 5.x 上安装邮件系统postfix+extmail+courier-imap
安装步骤.
1.系统准备
使用默认方式安装系统后,从RHEL安装盘上拷贝一些下面安装步骤需要的rpm包先安装上。
-
rpm -ivh postgresql-devel-8.1.11-1.el5_1.1.i386.rpm
-
rpm -ivh expect-5.43.0-5.1.i386.rpm
-
rpm -ivh libtool-ltdl-devel-1.5.22-6.1.i386.rpm
-
-
rpm -ivh mysql-devel-5.0.45-7.el5.i386.rpm
-
rpm -ivh openldap-servers-2.3.43-3.el5.i386.rpm
-
rpm -ivh openldap-servers-sql-2.3.43-3.el5.i386.rpm
-
-
rpm -ivh pcre-6.6-2.el5_1.7.i386.rpm
-
rpm -ivh pcre-devel-6.6-2.el5_1.7.i386.rpm
再从 www.extmail.org 网站上下载最新的 extmail 相关包
extmail-1.1.0.tar.gz extman-1.0.0.tar.gz slockd-0.99.tar.gz
2.导入extman后台数据库数据
-
tar -xzvf extman-1.0.0.tar.gz
-
cd extman-1.0.0/docs
-
mysql -u root -p
-
mysql> source extmail.sql
-
mysql> source init.sql
-
mysql> exit
3.准备rpm环境变量
按照参考文档,采用rpm方式安装,首先设置环境变量,方便后面操作的目录切换。
-
export rpms=/usr/src/redhat/RPMS
-
export source=/usr/src/redhat/SOURCES
-
export spec=/usr/src/redhat/SPECS
4.安装authlib
a.下载源码包
-
wget http://prdownloads.sourceforge.net/courier/courier-authlib-0.61.0.tar.bz2
-
tar -xjf courier-authlib-0.61.0.tar.gz2
-
cd courier-authlib-0.61.0
-
cp courier-authlib.spc $spec
-
cd ..
-
cp courier-authlib-0.61.0.tar.gz2 $source
-
cd $spec
-
rpmbuild -bb courier-authlib.spec
b.安装生成的rpm
-
cd $rpms/i386
-
rpm -ivh courier-authlib-0.61.0-1.i386.rpm
-
rpm -ivh courier-authlib-devel-0.61.0-1.i386.rpm
-
rpm -ivh courier-authlib-mysql-0.61.0-1.i386.rpm
c.配置authlibdaemon
-
cd /etc/authlib
-
mv authdaemonrc authdaemonrc.bak
-
vi authdaemonrc
输入以下内容
authmodulelist="authmysql" authmodulelistorig="authmysql" daemons=10 authdaemonvar=/var/spool/authdaemon debug_login=2 defaultoptions="wbnodsn=1" loggeropts=""
d.配置authmysqlrc
-
mv authmysqlrc authmysqlrc.bak
-
vi authmysqlrc
输入以下内容
MYSQL_SERVER localhost MYSQL_USERNAME extmail MYSQL_PASSWORD extmail MYSQL_SOCKET /var/lib/mysql/mysql.sock MYSQL_PORT 3306 MYSQL_OPT 0 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 homedir MYSQL_NAME_FIELD name MYSQL_MAILDIR_FIELD maildir MYSQL_QUOTA_FIELD quota MYSQL_SELECT_CLAUSE SELECT username,password,"",uidnumber,gidnumber,\ CONCAT('/var/maildata/domains/',homedir), \ CONCAT('/var/maildata/domains/',maildir), \ quota, \ name \ FROM mailbox \ WHERE username = '$(local_part)@$(domain)'
e.启动authlib
-
service courier-authlib start
-
chmod 777 /var/spool/authdaemon/
5.安装courier-imap
不能使用root身份生成rpm,需要建立一个新的普通账号。
-
useradd tmpusr
软件包依赖需要openldap-server,我们在前面已经准备好(rpm创建好后可以删除)
建立需要的目录和设置环境变量
-
su – tmpusr
-
mkdir -p rpm/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
-
vi ~/.rpmmacros
输入如下内容
%_topdir /home/tmpusr/rpm
获取源码包
-
wget http://prdownloads.sourceforge.net/courier/courier-imap-4.4.1.tar.bz2
-
cp courier-imap-4.4.1.tar.bz2 rpm/SOURCES/
-
tar -xjf courier-imap-4.4.1.tar.bz2
-
cd courier-imap-4.4.1
-
cp courier-imap.spec ../rpm/SPECS/
-
cd ../rpm/SPECS/
编辑courier-imap.spec文件,将下面内容作修改
%if %suse_version BuildPreReq: rpm >= 3.0.5 /usr/bin/sed openldap2 openldap2-devel %([ %{suse_version} -gt 819 ] && echo /usr/include/fam.h) %else BuildPreReq: rpm >= 4.0.2 sed /usr/include/fam.h openldap-devel openldap-servers %endif
修改为
%if %suse_version BuildPreReq: rpm >= 3.0.5 /usr/bin/sed openldap2 openldap2-devel %else BuildPreReq: rpm >= 4.0.2 sed openldap-devel openldap-servers %endif
创建rpm,并使用exit退出当前用户
-
rpmbuild -bb courier-imap.spec
-
exit
安装生成好的rpm,并运行服务
-
rpm -ivh /home/tmpusr/rpm/RPMS/i386/courier-imap-4.4.1-1.i386.rpm
-
service courier-imap start
6.安装cyrus-sasl
a.安装srpm
-
wget ftp://194.199.20.114/linux/fedora/updates/8/SRPMS/cyrus-sasl-2.1.22-8.fc8.src.rpm
-
rpm -ivh cyrus-sasl-2.1.22-8.fc8.src.rpm
-
cd $spec
编辑cyrus-sasl.spec 将下面:
# bundling copy of berkeley db, for sasldb support. topdir=`pwd` pushd db-%{db_version}/build_unix ../dist/configure \r --with-mutex=unix/fcntl --disable-shared --enable-static --with-pic \ --with-uniquename=_cyrus_sasl_sasldb_rh \ --prefix=${topdir}/db-instroot \ --includedir=${topdir}/db-instroot/include \ --libdir=${topdir}/db-instroot/lib
改为:
# bundling copy of berkeley db, for sasldb support. topdir=`pwd` pushd db-%{db_version}/build_unix ../dist/configure \r --with-mutex=unix/fcntl --disable-shared --enable-static --with-pic \ --with-uniquename=_cyrus_sasl_sasldb_rh \ --prefix=${topdir}/db-instroot \ --includedir=${topdir}/db-instroot/include \ --libdir=${topdir}/db-instroot/lib \ --with-authdaemond=/var/spool/authdaemon
b、生成rpm并做安装
-
rpmbuild -bb cyrus-sasl.spec
-
cd $rpms/i386
-
rpm -e –nodeps cyrus-sasl-devel cyrus-sasl-plain cyrus-sasl cyrus-sasl-lib (如果这些包存在,先卸载)
-
rpm -ihv cyrus-sasl-lib-2.1.22-8.i386.rpm
-
rpm -ihv cyrus-sasl-2.1.22-8.i386.rpm
-
rpm -ihv cyrus-sasl-plain-2.1.22-8.i386.rpm
c、配置sasl2
创建/usr/lib/sasl2/smtpd.conf 文件,输入下面的内容:
pwcheck_method: authdaemond log_level: 3 mech_list: PLAIN LOGIN authdaemond_path:/var/spool/authdaemon/socket
7.安装postfix
a、下载软件包
-
cd ~
-
wget http://ftp.wl0.org/official/2.5/SRPMS/postfix-2.5.4-2.src.rpm
-
rpm -ivh postfix-2.5.4-2.src.rpm
-
cd $spec
编辑postfix.spec 修改下面的选项
%define distribution rhel-5.0 %define with_mysql_redhat 1 %define with_sasl 2 %define with_vda 1
b、创建rpm并做安装
-
rpmbuild -bb postfix.spec
-
cd $rpms/i386
-
rpm -ivh postfix-2.5.4-2.rhel4.i386.rpm
c、切换mta
-
alternatives –config mta (选择2,postfix)
-
rpm -e sendmail
-
cd /usr/sbin/
-
mv sendmail sendmail.bak
-
newaliases
-
ln -s sendmail.postfix sendmail
d、配置postfix
cd /etc/postfix/
mv main.cf main.cf.bak
vi main.cf
输入下面的内容:
queue_directory = /var/spool/postfix command_directory = /usr/sbin daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix mail_owner = postfix unknown_local_recipient_reject_code = 550 debug_peer_level = 2 debugger_command = path=/bin:/usr/bin:/usr/local/bin:/usr/x11r6/bin ddd $daemon_directory/$process_name $process_id & sleep 5 sendmail_path = /usr/sbin/sendmail.postfix newaliases_path = /usr/bin/newaliases.postfix mailq_path = /usr/bin/mailq.postfix setgid_group = postdrop html_directory = /usr/share/doc/postfix-2.5.2-documentation/html manpage_directory = /usr/share/man sample_directory = /etc/postfix readme_directory = /usr/share/doc/postfix-2.5.2-documentation/readme alias_database = hash:/etc/postfix/aliases alias_maps = hash:/etc/postfix/aliases myhostname = mail.mymailserver.org mydomain = mymailserver.org mydestination = $myhostname smtpd_banner = mymailserver.org esmtp mail system virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf virtual_mailbox_base = /var/maildata/domains virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_limit_maps.cf virtual_transport = maildrop: maildrop_destination_recipient_limit = 1 #sasl smtpd_sasl_auth_enable = yes smtpd_sasl2_auth_enable = yes smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes # smtpd related config smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_hostname, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unauth_destination, reject_unauth_pipelining, reject_invalid_hostname
可以将如上最后一段替换成如下:对邮件收发进-不控制:
--------------------------------------------------- #setting by king smtpd_recipient_restrictions=permit_mynetworks, permit_sasl_authenticated, reject_invalid_hostname, reject_non_fqdn_hostname, reject_unknown_sender_domain, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_unauth_pipelining, reject_unauth_destination
复制extman/docs 目录的mysql_virtual_*.cf 文件到/etc/postfix
-
cp /root/ExtSuite/extman-1.0.0/docs/mysql_virtual_* .
因为配置文件的用户、密码与数据库时1样,所以不用修改.
-
service postfix start
8.安装maildrop
a.下载生成rpm
-
cd ~
-
wget http://prdownloads.sourceforge.net/courier/maildrop-2.0.4.tar.bz2
-
cp maildrop-2.0.4.tar.bz2 $source
-
tar xjf maildrop-2.0.4.tar.bz2
-
cd maildrop-2.0.4
-
cp maildrop.spec $spec
-
cd $spec
编辑maildrop.spec 把下面:
BuildRequires: /usr/include/fam.h gdbm-devel pcre-devel
改为:
BuildRequires: gdbm-devel pcre-devel
把下面:
%configure --with-devel --enable-userdb --enable-maildirquota \ --enable-syslog=1 --enable-trusted-users='root mail daemon postmaster qmaild mmdf' \ --enable-restrict-trusted=0 \r --enable-sendmail=/usr/sbin/sendmail
改为:
%configure --with-devel --enable-userdb --enable-maildirquota \ --enable-syslog=1 --enable-trusted-users='root mail daemon postmaster qmaild mmdf' \ --enable-restrict-trusted=0 --enable-sendmail=/usr/sbin/sendmail \ --enable-authlib
说明:如果tail -f /var/log/maillog 提示“maildrop: maildir over quota”,可以将
“--enable-maildirquota ”配置选项清除,既可以解决maildrp 误报“maildir over quota”错误.
b.创建maildrop rpm并安装
-
rpmbuild -bb maildrop.spec
-
cd $rpms/i386
-
rpm -ivh maildrop-2.0.4-1.i386.rpm
-
rpm -ivh maildrop-devel-2.0.4-1.i386.rpm
c.添加虚似用户及创建目录
-
cd ~
-
groupadd -g 1000 vgroup
-
useradd -g 1000 -u 1000 -s /sbin/nologin -d /dev/null vuser
编辑/etc/postfix/master.cf ,加入下面的内容:
maildrop unix - n n - - pipe flags=DRhu user=vuser argv=/usr/bin/maildrop -d ${user}@${nexthop} ${recipient} ${user} ${extension} ${nexthop}
或者:
--------------------------------------- maildrop unix - n n - - pipe flags=DRhu user=vuser argv=maildrop -w 90 -d ${user}@${nexthop} ${recipient} ${user} ${extension} {nexthop}
或者:
------------------------------------------------ maildrop unix - n n - - pipe flags=DRhu user=vuser argv=/usr/bin/maildrop -d ${recipient}
或者:
------------------------------------------------- #maildrop unix - n n - - pipe # flags=DRhu user=vuser argv=/usr/bin/maildrop -d ${user}@${nexthop} ${recipient} ${user} ${extension} ${nexthop}
d.创建邮件存储目录
-
mkdir -p /var/maildata/domains/extmail.org/postmaster
-
maildirmake /var/maildata/domains/extmail.org/postmaster/Maildir
-
chown -R vuser:vgroup /var/maildata/domains/
e.测试maildrop
-
echo "test" | maildrop -v 10 -d postmaster@extmail.org
显示出
maildrop: authlib: groupid=1000 maildrop: authlib: userid=1000 maildrop: authlib: logname=postmaster@extmail.org, home=/var/maildata/domains/extmail.org/postmaster, mail=/var/maildata/domains/extmail.org/postmaster/maildir/ maildrop: changing to /var/maildata/domains/extmail.org/postmaster message start at 0 bytes, envelope sender=postmaster@extmail.org maildrop: attempting .mailfilter maildrop: delivery complete.出现上以信息说明authlib,maildrop 工作正常f.测试pop3
显示出如下信息作操作
[root@localhost ~]# telnet localhost 110trying 127.0.0.1... connected to localhost.localdomain (127.0.0.1). escape character is '^]'. +ok hello there. user postmaster@extmail.org +ok password required. pass extmail +ok logged in. list +ok pop3 clients that break here, they violate std53. 1 6 . retr 1 +ok 6 octets follow. test . quit +ok bye-bye. connection closed by foreign host.g.测试postfix
[root@localhost ~]# perl -e 'use MIME::Base64; print encode_base64("postmaster\@extmail.org")' cG9zdG1hc3RlckBleHRtYWlsLm9yZw== [root@localhost ~]# perl -e 'use MIME::Base64; print encode_base64("extmail")' ZXh0bWFpbA== [root@localhost ~]# service postfix restart (重启1下) [root@localhost ~]# telnet localhost 25 trying 127.0.0.1... connected to localhost.localdomain (127.0.0.1). escape character is '^]'. 220 mymailserver.org esmtp mail system ehlo test.com 250-mail.mymailserver.org 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-AUTH LOGIN PLAIN 250-AUTH=LOGIN PLAIN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN auth login 334 VXNlcm5hbWU6 cG9zdG1hc3RlckBleHRtYWlsLm9yZw== 334 UGFzc3dvcmQ6 ZXh0bWFpbA== 235 2.0.0 Authentication successful quit 221 2.0.0 Bye Connection closed by foreign host.9.安装extmail
a.拷贝extmail目录
[root@localhost ~]# mkdir /var/www/extsuite [root@localhost ~]# cp -r extmail-1.1.0 /var/www/extsuite/extmail [root@localhost ~]# cp -r extman-1.0.0 /var/www/extsuite/extmanb、配置extmail参数
[root@localhost ~]# cd /var/www/extsuite/extmail/ [root@localhost extmail]# cp webmail.cf.default webmail.cf修改webmail.cf 下面的选项
sys_sess_dir = /tmp/extmail sys_maildir_base = /var/maildata/domains sys_mysql_user = extmail sys_mysql_pass = extmailc、配置extman参数
[root@localhost extmail]# cd /var/www/extsuite/extman/修改webman.cf 下面的选项:
sys_maildir_base = /var/maildata/domainsd、创建session 目录
[root@localhost extman]# mkdir /tmp/{extman,extmail} [root@localhost extman]# chown vuser:vgroup /tmp/ext*e、在nginx服务器上做虚拟机配置
修改nginx.conf 添加extmail的目录设置
server { listen 80; server_name mail.mymailserver.org index index.html index.htm index.cgi; root /var/www/extsuite/extmail/html/; location /extmail/cgi/ { fastcgi_param SCRIPT_FILENAME /var/www/extsuite$fastcgi_script_name; include perl.conf; } location /extmail/ { alias /var/www/extsuite/extmail/html/; } location /extman/cgi/ { fastcgi_param SCRIPT_FILENAME /var/www/extsuite/$fastcgi_script_name; include perl.conf; } location /extman/ { alias /var/www/extsuite/extman/html/; } }perl.conf内容
fastcgi_pass unix:/tmp/perl_fcgi.socket; #fastcgi_pass 127.0.0.1:8888 fastcgi_index index.cgi; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; fastcgi_read_timeout 60;perl的fastcgi配置参考前面写的为了Awstats给Nginx添加FastCGI方式的Perl支持 也可以使用extmail包中附带的 dispatch.fcgi
/var/www/extsuite/extmail/dispatch.fcgi --port=8888 --child=4 --server \ --uid=vuser --gid=vgroup --pid=/var/run/dispatch.fcgi.pid \ --request=50 --timeout=120f、访问extmail/extman
打开浏览器,输入http://your_ip_address/extmail 注意:your_ip_address 为你实际的ip
第1个测试用户为:postmaster 密码:extmail 域:extmail, 登陆以后修改密码做测试。打开浏览器,输入http://your_ip_address/extman
extman的默认 root 用户为:root@extmail.org 密码为:extmail*123*
进入系统后首先修改密码,然后做系统的设置.Popularity: 13% [?]
Related
Comments
2 Responses to “在RHEL5.3上安装基于postfix的extmail邮件系统”
[root@localhost init.d]# echo “test” | maildrop -v 10 -d postmaster@extmail.org
maildrop 2.0.4 Copyright 1998-2005 Double Precision, Inc.
GDBM extensions enabled.
Courier Authentication Library extension enabled.
Maildir quota extension enabled.
This program is distributed under the terms of the GNU General Public
License. See COPYING for additional information.
-bash: echo: write error: 断开的管道
我每次到这步都提示这个的错误。郁闷,找了好多资料都解决不了。兄台可否指导一下?谢谢!
(我用的系统是 centos5.3)
[Reply]
dvd Reply:
March 16th, 2010 at 3:59 pm
echo “test” | maildrop -V 10 -d postmaster@extmail.org
引号改成英文格式的
[Reply]