天天看點

CentOS5.4+postfix+dovecot+sasl+openwebmail配置手記

最近接觸了一套新的郵件系統,使用的是Postfix的。

以前不太熟悉,照着機關的文檔和網上的教程,加上一些自己的修改就形成了這個文檔。

2010年7月7日---在新的機器上重新部署的時候發現MailScanner程序CPU占用率很高,重新開機依舊,而且還會報錯。

照着第四個參考連結修改了一下MailScanner和virus.scanners的配置檔案就沒事了。

抽空還要研究一下讓郵件改用nod32.

真的很複雜啊。

過程基本都用yum的方式,需要用到rpmforge和openwebmail的源。

參考連接配接如下:

<a href="http://linux.chinaitlab.com/administer/774651.html">http://linux.chinaitlab.com/administer/774651.html</a>

<a href="http://blog.chinaunix.net/u/10047/showart_311977.html">http://blog.chinaunix.net/u/10047/showart_311977.html</a>

<a href="http://ciscolj.blog.51cto.com/330452/167427">http://ciscolj.blog.51cto.com/330452/167427</a>

<a href="http://bbs.chinaunix.net/viewthread.php?tid=1033019">http://bbs.chinaunix.net/viewthread.php?tid=1033019</a>

具體步驟如下:

1. 修改主機名

#vi /etc/sysconfig/network

HOSTNAME=mail.ywtest.com

#hostname mail.ywtest.com

2. 安裝配置DNS

#yum install bind bind-chroot caching-nameserver

DNS具體配置方法參考:

#chkconfig named on

#service named restart

#vi /etc/resolv.conf

3. 安裝Postfix、dovecot、openwebmail

#cd /etc/yum.repos.d

#yum install postfix dovecot openwebmail

4. 配置dovecot

#vi /etc/dovecot.conf

dovecot具體配置方法參考:

<a href="http://linux.chinaitlab.com/administer/774651_4.html">http://linux.chinaitlab.com/administer/774651_4.html</a>

#chkconfig dovecot on

#service dovecot restart

5. 配置Postfix

#service sendmail stop

#chkconfig sendmail off

#chkconfig postfix on

#service postfix start

#alternatives --config mta

#vi /etc/postfix/main.cf

修改或添加下列内容:(這些都是基本配置,其他關于sasl、收信發信過濾的配置以後還要多學習。)

myhostname = mail.ywtest.com

mydomain = ywtest.com

myorigin = $mydomain  (= $myhostname也可以)

inet_interfaces = all

mail_spool_directory = /var/spool/mail

mailbox_command = /usr/bin/procmail  (修改procmail的權限,g+s。在/etc/procmailrc中加入LOGFILE=/var/log/mail/procmail.log,修改mail目錄的權限。很多教程裡都沒有關于procmail的配置;Postfix預設沒有指定郵件投遞程式,是以這個不做的話郵件能傳遞,不能被投遞。procmail.log檔案664權限,root.mail所有。)

smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)  (自願添加)

#vi /etc/postfix/access  寫入mail.ywtest.com  OK、ywtest.com  OK、192.168.10  OK

#postmap /etc/postfix/access

#smtpd_client_restrictions = permit_sasl_authenticated

#smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination

6. 測試postfix、dovecot端口

#netstat -altpn|grep 25

#netstat -altpn|grep 110

#netstat -altpn|grep 143

#netstat -altpn|grep 993

#netstat -altpn|grep 995

PS:有必要修改iptables的配置,/etc/sysconfig/iptables。

7. 測試指令行方式的郵件收發

#mutt -f pop://[email protected]  (mutt可以收發郵件,具體用法不做解釋。)

8. 配置sasl

#vi /etc/sysconfig/saslauthd

修改或添加下列内容:

MECH=shadow

#chkconfig saslauthd on

#service saslauthd start

先要有httpd,不過預設的安裝就可以了,是以不多說了。

openwebmail具體配置方法參考:

#vi /var/www/cgi-bin/openwebmail/etc/openwebmail.conf

domainnames    ywtest.com

default_language    zh_CN.GB2312

default_timeoffset    +0800

default_iconset    Cool3D.Chinese.Simplified

#vi /var/www/cgi-bin/openwebmail/etc/defaults/openwebmail.conf

smtpserver    192.168.10.202

authpop3_server    192.168.10.202

#cd /var/www/cgi-bin/openwebmail

#./openwebmail-tool.pl --init

10.測試openwebmail

因為是rpm裝的ScriptAlias的配置已經自動添加了,裝了openwebmail之後記得重新開機httpd。

11.安裝Mail-SpamAssassin

本來想和别人一樣用rpmbuild的方法安裝,但是提示找不到/var/tmp/下的一個檔案,那個檔案命名存在。

後來改用yum的方法了,不知道後面會有什麼問題。

#yum -y install spamassassin

#chkconfig spamassassin on

#service spamassassin start

12.安裝MailScanner和install-Clam-SA

#tar zxf MailScanner-4.51.5-1.rpm.tar.gz

#tar zxf install-Clam-SA.tar.gz

#cd MailScanner-4.51.5-1

#./install.sh

#cd ../install-Clam-SA

時間真的很長。

具體參考:

13.配置

#vi /etc/mail/spamassassin/init.pre

取消下面插件的注釋,如果有的話:

loadplugin Mail::SpamAssassin::Plugin::Razor2

#vi /etc/MailScanner/MailScanner.conf

%org-name% = ywtest

%org-long-name% = ywtest

Run As User = postfix

Run As Group = postfix

Incoming Work User = postfix

Incoming Work Group = postfix

Incoming Queue Dir = /var/spool/postfix/hold

Outgoing Queue Dir = /var/spool/postfix/incoming

Quarantine User = postfix

Quarantine Group = postfix

MTA = postfix

Virus Scanning = yes

Virus Scanners = clamav

調整下列目錄權限:

#chown postfix.postfix mqueue -R

#chown postfix.postfix mqueue.in/ -R

#chown postfix.postfix MailScanner/ -R

#chown postfix.postfix postfix/ -R

*.ywtest.com是我自己常用的測試用域名,不是真正能解析的。

其他:

通路mail.ywtest.com直接看到openwebmail登陸界面:

建立opwebmail的虛拟主機:

NameVirtualHost *:80

&lt;VirtualHost *:80&gt;

    ServerName mail.ywtest.com

    DocumentRoot "/usr/local/apache/htdocs/openwebmail"

    Alias /data /usr/local/apache/data

    ErrorLog "logs/mail.ywtest.com-error_log"

    CustomLog "logs/mail.ywtest.com-access_log" combined

&lt;/VirtualHost&gt;

#vi index.html  建立index.html頁面,内容如下:

&lt;html&gt;

&lt;body onload=

"window.open('http://mail.ywtest.com/cgi-bin/openwebmail/openwebmail.pl','_top')"&gt;

&lt;/body&gt;

&lt;/html&gt;

本文轉自 sharkyan 51CTO部落格,原文連結:http://blog.51cto.com/sharkyan/313095,如需轉載請自行聯系原作者

繼續閱讀