postfix+dovecot+Cyrus-sasl+postfixadmin 郵件服務器設置

postfix+dovecot+Cyrus-sasl+postfixadmin 郵件服務器設置

    近來一直在擺弄postfix,想搞一套整郵件服務器,本來是想在openbsd4.8上實驗滴,可惜package滴問題作罷了,以後慢慢再搞吧。現將本次實驗的記錄貼出來,備將來查找。

 

1.本次實驗平臺 CentOS5 (關閉selinux服務)

所用到的軟件:

    Apache

    Php       

    Msysql

    Dovecot

    Cyrus-sasl

Postifix-2.6-20090404.tar.gz (因爲要支持mysqlsasl,所以用源碼包)

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章