rpm -ivh courier-authlib-mysql-0.62.2-1.i386.rpm
配置authlibdaemon
mv /etc/authlib/authdaemonrc /etc/authlib/authdaemonrc.save
vi /etc/authlib/authdaemonrc
输入如下内容:
authmodulelist="authmysql"
authmodulelistorig="authmysql"
daemons=10
authdaemonvar=/var/spool/authdaemon
DEBUG_LOGIN=2
DEFAULTOPTIONS="wbnodsn=1"
LOGGEROPTS=""
配置authmysqlrc
mv /etc/authlib/authmysqlrc /etc/authlib/authmysqlrc.save
vi /etc/authlib/authmysqlrc
输入如下内容:
MYSQL_SERVER localhost
MYSQL_USERNAME extmail
MYSQL_PASSWORD extmail
MYSQL_PORT 0
MYSQL_SOCKET /var/lib/mysql/mysql.sock
MYSQL_OPT 0
MYSQL_DATABASE extmail
MYSQL_SELECT_CLAUSE SELECT username,password,"",uidnumber,gidnumber,\
CONCAT('/home/data/domains/',homedir), \
CONCAT('/home/data/domains/',maildir), \
quota, \
name \
FROM mailbox \
WHERE username = '$(local_part)@$(domain)'
启动authlib服务
service courier-authlib start
chmod 777 /var/spool/authdaemon
chkconfig --level 3 courier-authlib on
安装courier-imap
yum -y install fam-devel openldap-servers
这里要注意不能用root身份生成rpm包
useradd quan
passwd quan
su - quan
mkdir -p rpm/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
vi ~/.rpmmacros
%_topdir /home/quan/rpm
tar zxvf courier-imap-4.4.1.tar.bz2
cp courier-imap-4.4.1.tar.bz2 ~/rpm/SOURCES
cd courier-imap-4.4.1
cp courier-imap.spec ~/rpm/SPECS
cd ~/rpm/SPECS
vi 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包
rpmbuild -bb courier-imap.spec
退出quan用户:exit
安装courier-imap包
rpm -ivh /home/quan/rpm/RPMS/i386/courier-imap-4.4.1-1.i386.rpm
启动服务
service courier-imap start
chkconfig --level 3 courier-imap on
cyrus-sasl采用系统自带的2.1.22版本
确保有以下包的存在
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
rpm -ivh cyrus-sasl-devel-2.1.22-8.i386.rpm
vi /usr/lib/sasl2/smtpd.conf
pwcheck_method:authdaemond
log_level:3
mech_list:PLAIN LOGIN
authdaemond_path:/var/spool/authdaemon/socket
安装postfix
wget http://ftp.wl0.org/official/2.5/SRPMS/postfix-2.5.4-2.src.rpm
和上面一样制作rpm 包
这里编辑下 postfix.spec 文件,修改下面对应内容,修改好后为:
%define distribution rhel-5.0
%define with_mysql_redhat 1
%define with_sasl 2
%define with_vda 1
生成rpm 包,并安装,安装方法和上面一样,在RPMS 文件夹里面你可以找到postfix 的rpm 包。
切换系统默认的MTA
alternatives --config mta (选择2,postfix)
rpm �Ce sendmail
cd /usr/sbin/
mv sendmail sendmail.bak
newaliases
ln -s sendmail.postfix sendmail
配置Postfix
cd /etc/postfix
mv main.cf main.cf.backup
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 = quan.mail
mydomain = quanmail.com
mydestination = $myhostname
smtpd_banner = quanmail.com ESMTP Mail System
message_size_limit = 14680064
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_base = /home/data/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_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination,reject_unauth_pipelining,
reject_invalid_hostname
复制 extman/docs 目录下所有 .cf 文件到/etc/postfix
cp /usr/local/src/extman-0.2.5/docs/mysql_virtual_* . /etc/postfix
因为配置文件的用户、密码与刚开始导入extmail 数据库时一样,所以不用修改。
启动postfix
service postfix start
chkconfig --level 3 postfix on