2012年3月21日 星期三

Postfix 安裝設定

OS:CentOS-5.6-x86_64

郵件系統:Postfix + Dovecot + Openwebmail
垃圾信過濾:RBL 網站, Postgrey


yum install postfix
/etc/init.d/sendmail stop
yum remove sendmail sendmail-cf
/etc/init.d/postfix start
chkconfig postfix on



/etc/postfix/main.cf 

myhostname = ms1.domain.com.tw
mydomain = domain.com.tw
myorigin = $mydomain
inet_interfaces = all
mydestination =  $myhostname, $mydomain
mynetworks = 192.168.200.0/24, 192.168.1.0/24, 127.0.0.0/8
relay_domains = $mydestination

smtpd_recipient_restrictions =
permit_mynetworks
permit_sasl_authenticated
reject_unknown_sender_domain
reject_unknown_recipient_domain
reject_unauth_destination
reject_rbl_client cbl.abuseat.org
reject_rbl_client bl.spamcop.net
reject_rbl_client cblless.anti-spam.org.cn
reject_rbl_client sbl-xbl.spamhaus.org
check_policy_service unix:/var/spool/postfix/postgrey/socket

smtpd_client_restrictions =
permit_mynetworks
permit_sasl_authenticated
check_client_access hash:/etc/postfix/access
reject_rbl_client cbl.abuseat.org
reject_rbl_client bl.spamcop.net
reject_rbl_client cblless.anti-spam.org.cn
reject_rbl_client sbl-xbl.spamhaus.org

smtpd_sender_restrictions =
reject_non_fqdn_sender
reject_unknown_sender_domain

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes

message_size_limit = 10000000
mailbox_size_limit = 1000000000

maximal_queue_lifetime = 5d

postalias /etc/aliases
postmap /etc/postfix/access
postfix reload



/etc/dovecot.conf 
protocols = imap pop3 

/usr/lib64/sasl2/smtpd.conf 
log_level: 3
pwcheck_method: saslauthd
mech_list: plain login


/etc/init.d/saslauthd start
chkconfig saslauthd on

Httpd 設定:
/etc/httpd/conf/httpd.conf 
ScriptAlias /mail "/var/www/cgi-bin/openwebmail/openwebmail.pl 


openwebmail
先安裝 perl-Text-Iconv
http://www.openwebmail.org/openwebmail/download/redhat/rpm/packages/centos5/perl-Text-Iconv/i386/perl-Text-Iconv-1.7-2.el5.i386.rpm


/etc/yum.repos.d/openwebmail.repo
[openwebmail]
## Thomas Chung
## 2008.05.29
name=Openwebmail for Fedora or Enterprise Linux
baseurl=http://openwebmail.org/openwebmail/download/redhat/rpm/release/
enabled=1
gpgcheck=1
gpgkey=http://openwebmail.org/openwebmail/download/redhat/rpm/release/RPM-GPG-KEY-openwebmail
#metadata_expire=0

yum -y  install openwebmail
cd /var/www/cgi-bin/openwebmail/
./openwebmail-tool.pl  –init

/var/www/cgi-bin/openwebmail/etc/dbm.conf 
dbm_ext                 .db
dbmopen_ext             .db
dbmopen_haslock         yes


cd /var/www/cgi-bin/openwebmail/
./openwebmail-tool.pl  –init

/var/www/cgi-bin/openwebmail/etc/openwebmail.conf 
default_language                zh_TW.Big5
default_iconset                 Cool3D.Chinese.Traditional


P.S.
SELinux 造成登入出現錯誤訊息:
touch /var/log/openwebmail.log
chcon -u system_u /var/log/openwebmail.log
chcon -t httpd_sys_script_rw_t /var/log/openwebmail.log
chcon -t httpd_unconfined_script_exec_t /var/www/cgi-bin/openwebmail/openwebmail*

separate domains, UNIX system accounts
Virtual Domain:Vdomain1.tw, Vdomain2.tw

useradd -g Mail_Group -s /sbin/nologin UserA.Vdomain1

/etc/postfix/main.cf 
virtual_alias_domains = Vdomain1.tw, Vdomain2.tw
virtual_alias_maps = hash:/etc/postfix/virtual_alias_maps


/etc/postfix/virtual_alias_maps 
Vdomain1.tw anything
Vdomain2.tw anything

UserA@Vdomain1.tw UserA.Vdomain1
UserA@Vdomain2.tw UserA.Vdomain2
mailadmin@Vdomain1.tw mailadmin


postmap /etc/postfix/virtual_alias_maps

cd /var/www/cgi-bin/openwebmail/etc
cp openwebmail.conf ./sites.conf/ms1.Vdomain1.tw
cp openwebmail.conf ./sites.conf/ms1.Vdomain2.tw 

/var/www/cgi-bin/openwebmail/etc/sites.conf/ms1.Adomain1.tw 
domainnames                     Vdomain1.tw
logo_url                        %ow_htmlurl%/images/logo3.png
logo_link                       http://www.Vdomain1.tw
enable_pop3                    no
enable_changepwd               no
enable_history                 no
enable_about                   no
quota_module            quota_du.pl
#spool_limit             10240
quota_limit             1048576
quota_threshold         0
#delmail_ifquotahit      no
#delfile_ifquotahit      no
enable_webdisk no
enable_calendar no
#auth_withdomain yes
#auth_domain Adomain1.tw