postfix+dovecot+Cyrus-sasl+postfixadmin 邮件服务器设置
近来一直在摆弄postfix,想搞一套整邮件服务器,本来是想在openbsd4.8上实验滴,可惜package滴问题作罢了,以后慢慢再搞吧。现将本次实验的记录贴出来,备将来查找。
1.本次实验平台 CentOS5 (关闭selinux服务)
所用到的软件:
Apache
Php
Msysql
Dovecot
Cyrus-sasl
Postifix-2.6-20090404.tar.gz (因为要支持mysql和sasl,所以用源码包)
Postfixadmin-2.3.2.tar
Clamav (yum 安装)
Amavisd-new (yum安装)
nocc-1.7.tar.gz (一个webmail,感觉比较小巧)
2.安装postfix
[root@mycentos postfix-2.6-20090404]#useradd -s /bin/false postfix
[root@mycentos postfix-2.6-20090404]#groupadd postdrop
[root@mycentos postfix-2.6-20090404]#make -f Makefile.init makefiles \
'CCARGS=-DHAS_MYSQL -I/usr/include/mysql –DUSE_SASL_AUTH –DUSE_CYRUS_SASL –I/usr/include/sasl' \
'AUXLIBS=-L/usr/lib/mysql/ -lmysqlclient -lz –lm –L/usr/lib –lsasl2 '
[root@mycentos postfix-2.6-20090404]#make &&make install
3.修改配置文件./etc/postfix/main.cf
#=====================BASE=========================
myhostname = mycentos.max.com
mydomain = max.com
myorigin = $mydomain
mydestination = $myhostname localhost localhost.$mydomain
mynetworks = 127.0.0.0/8
inet_interfaces = all
#=====================Vritual Mailbox settings=========================
virtual_minimum_uid = 500 (postfix 的id)
virtual_mailbox_base = /var/spool/mail
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_alias_domains =
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_uid_maps = static:500 (postfix 的id)
virtual_gid_maps = static:500 (postfix 的id)
virtual_transport = virtual
maildrop_destination_recipient_limit = 1
maildrop_destination_concurrency_limit = 1
#====================QUOTA========================
message_size_limit = 52428800
mailbox_size_limit = 209715200
virtual_mailbox_limit = 209715200
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please try again later.
virtual_overquota_bounce = yes
#====================SASL========================
broken_sasl_auth_clients = yes
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,permit
smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = /var/run/dovecot/auth-client
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_sasl_application_name = smtpd
smtpd_banner=$myhostname ESMTP "Version not Available"
readme_directory = no
sample_directory = /etc/postfix
sendmail_path = /usr/sbin/sendmail
html_directory = no
setgid_group = postdrop
command_directory = /usr/sbin
manpage_directory = /usr/local/man
daemon_directory = /usr/libexec/postfix
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
queue_directory = /var/spool/postfix
mail_owner = postfix
data_directory = /var/lib/postfix
增加配置文件 mysql_virtual_alias_maps.cf
user = postfix
password = postfixadmin
hosts = localhost
dbname = postfix
table = alias
select_field = goto
where_field = address
增加配置文件 mysql_virtual_domain_maps.cf
user = postfix
password = postfixadmin
hosts = localhost
dbname = postfix
table = domain
select_field = description
where_field = domain
增加配置文件 mysql_virtual_mailbox_maps.cf
user = postfix
password = postfixadmin
hosts = localhost
dbname = postfix
table = mailbox
select_field = maildir
where_field = username
增加配置文件 mysql_virtual_mailbox_limit_maps.cf
user = postfix
password = postfixadmin
hosts = localhost
dbname = postfix
table = mailbox
select_field = quota
where_field = username
4.配置sasl验证
[root@mycentos postfix]# cat /usr/lib/sasl2/smtpd.conf
pwcheck_method:saslauthd
mech_list: plain login
[root@mycentos postfix]# cat /etc/sysconfig/saslauthd
# Directory in which to place saslauthd's listening socket, pid file, and so
# on. This directory must already exist.
SOCKETDIR=/var/run/saslauthd
# Mechanism to use when checking passwords. Run "saslauthd -v" to get a list
# of which mechanism your installation was compiled with the ablity to use.
MECH=shadow
# Additional flags to pass to saslauthd on the command line. See saslauthd(8)
# for the list of accepted flags.
FLAGS=
5.安装配置dovecot
[root@mycentos postfix]# rpm -ivh /mnt/CentOS/dovecot-1.0.7-7.el5.i386.rpm
修改/etc/dovecot.conf
[root@mycentos postfix]# cat /etc/dovecot.conf
base_dir=/var/run/dovecot
protocols=imap pop3
listen=*
disable_plaintext_auth = no
ssl_disable = yes
mail_location = maildir:/var/spool/mail/%d/%n
auth default {
mechanisms = PLAIN LOGIN CRAM-MD5 DIGEST-MD5
passdb sql {
args =/etc/dovecot-mysql.conf
}
userdb sql {
args =/etc/dovecot-mysql.conf
}
socket listen {
client {
path = /var/run/dovecot/auth-client
mode = 0660
user = postfix
group = postfix
}
}
}
first_valid_uid = 500
增加 /etc/dovecot-mysql.conf
[root@mycentos postfix]# cat /etc/dovecot-mysql.conf
driver = mysql
connect = host=/var/lib/mysql/mysql.sock dbname=postfix user=postfix password=postfixadmin
default_pass_scheme = MD5
password_query = SELECT password FROM mailbox WHERE username = '%u'
user_query = SELECT maildir, 500 AS uid, 500 AS gid FROM mailbox WHERE username = '%u'
6.安装配置postfixadmin
将Postfixadmin-2.3.2.tar解压到/var/www/html中,由于此版本中没有DATABASE_MYSQL.TXT文件 我是从postfixadmin-2.1.0.tar中提取,导入到mysql中:
[root@mycentos html]# mysql -u root -p <DATABASE_MYSQL.TXT
在mysql中增加postfix用户密码为postfixadmin
mysql> grant all on postfix.* to 'postfix'@'localhost' identified by 'postfixadmin';
修改中/var/www/postfixadmin/config.inc.phpf的相关配置
$CONF['configured'] = true;
$CONF['default_language'] = 'cn';
$CONF['database_type'] = 'mysql';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfix';
$CONF['database_password'] = 'postfixadmin';
$CONF['database_name'] = 'postfix';
$CONF['domain_path'] = 'YES';
$CONF['domain_in_mailbox'] = 'NO';
修改/var/spool/mail权限:
[root@mycentos spool]# ll -d mail
drwxrwxr-x 3 postfix postfix 4096 Dec 1 19:31 mail
到目前为止一个基本postfix+dovecot+Cyrus-sasl+postfixadmin完成感谢http://51CTO提醒您,请勿滥发广告!/bbs/ 橡皮树老师滴配置文件
参考文档:
http://www.postfix.org/documentation.html
http://www.sbear.cn/postfix.rar