免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123下一页
最近访问板块 发新帖
查看: 18689 | 回复: 21
打印 上一主题 下一主题

[Mail] RHEL5上安装邮件系统Postfix+Cyrus SASL+dovecot+MailScanner+spamassassin+f-prot [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-06-20 10:21 |只看该作者 |倒序浏览
RHEL5上安装邮件系统Postfix+CyrusSASL+dovecot+MailScanner+spamassassin+f-prot

LEO

默认方式安装RHEL5,不选中任何类型服务器(如WEB服务器,开发服务器,虚拟服务器等)

安装postfix
[root@rhel5 ~]# /etc/rc.d/init.d/sendmail stop
关闭 sm-client:                                            [确定]
关闭 sendmail:                                            [确定]
[root@rhel5 ~]# chkconfig sendmail off
[root@rhel5 Server]# rpm -ivh postfix-2.3.3-2.i386.rpm
[root@rhel5 Server]# vi /etc/postfix/main.cf
myhostname = mail.mailidc.cn    #设置运行postfix服务的邮件主机的主机名、域名
mydomain = mailidc.cn      
myorigin = $mydomain      #设置由本机寄出的邮件所使用的域名或主机名称
inet_interfaces = all         #设置postfix服务监听的网络接口
mydestination = $myhostname, $mydomain, localhost.$mydomain, localhost    #设置可接收邮件的主机名称或域名
mynetworks = 127.0.0.1         #设置可转发哪些网络的邮件
relay_domains = $mydestination  #设置可转发哪些网域的邮件
保存文件。
检查postfix的配置:
[root@rhel5 Server]# postconf –n
[root@rhel5 ~]# chkconfig postfix on
將postfix加入到root的组:
# usermod -G root postfix

SMTP认证的配置
安装cyrus-sasl
1、确认cyrus-sasl是否安装了
[root@rhel5 Server]# rpm -qa|grep cyrus
cyrus-sasl-plain-2.1.22-4
cyrus-sasl-lib-2.1.22-4
cyrus-sasl-2.1.22-4

Cyrus-SASL V2的密码验证机制
[root@rhel5 ~]# saslauthd -v
saslauthd 2.1.22
authentication mechanisms: getpwent kerberos5 pam rimap shadow ldap
我们准备用的是shadow的密码验证机制。

vi /etc/sysconfig/saslauthd
MECH=shadow
启动sasl的daemon并测试:
# service saslauthd start
# /usr/sbin/testsaslauthd -u 帐号 -p '密码'
0: OK "Success."   =>帐号验证成功了
[root@rhel5 ~]# chkconfig saslauthd on

设置postfix启用SMTP认证
[root@rhel5 Server]# vi /etc/postfix/main.cf
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain= ''
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,
           reject_unauth_destination
broken_sasl_auth_clients = yes
smtpd_client_restrictions = permit_sasl_authenticated
smtpd_sasl_security_options = noanonymous

wq!保存

此外,由于当postfix要使用SMTP认证时,会读取/usr/lib/sasl2/smtpd.conf文件的内容以确定所采用的认证方式,所以必须保证/usr/lib/sasl2/smtpd.conf文件的内容是:
pwcheck_method: saslauthd

安装设定dovecot(imap、pop3):
1、确认dovecot是否有安装:
[root@rhel5 ~]# rpm -qa|grep dovecot
dovecot-1.0-1.2.rc15.el5
2、设定用pop3来收取信件:
#vi /etc/dovecot.conf
protocols = pop3   #  imap imaps pop3 pop3s 支持的功能
3、启动并测试:
#service dovecot start
# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK dovecot ready.
user 账号
+OK
pass 密码
+OK Logged in.
[root@rhel5 ~]# chkconfig dovecot on

到这里postfix、Cyrus SASL、dovecot就可以正常工作了。

----------------------------------------------------------------------------------------------------------------------

让postfix支持MailScanner、spamassassin、f-prot
A、安装 F-PROT (F-PROT Antivirus for Linux)
http://files.f-prot.com/files/linux-x86/fp-linux-ws.rpm下载 f-prot
[root@rhel5 ~]# rpm -ivh fp-linux-ws.rpm

B、安装MailScanner
下载http://www.mailscanner.info/file ... 4.60.8-1.rpm.tar.gz
版本.rpm.tar.gz
(这里可能会少些perl的套件,出现错误讯息!请照着错误讯息要的rpm装完即可!)
# tar zxvf MailScanner-4.60.8-1.rpm.tar.gz
# cd MailScanner-4.60.8-1
# ./install.sh

C、安装spamassassin
1、确认spamassassin是否有安装:
# rpm -qa |grep spam
如没有安装就安装该包
[root@rhel5 Server]# rpm -ivh spamassassin-3.1.7-4.el5.i386.rpm

2建立Mailscanner支持spamassassin所需的目录:
# mkdir /var/spool/MailScanner/spamassassin
# chmod 700 /var/spool/MailScanner/spamassassin
# chown postfix.postfix /var/spool/MailScanner/spamassassin

3、修改spamassassin的设定档local.cf
可到站点http://www.yrex.com/spam/spamconfig.php自动生成local.cf的内容。
# vi /etc/mail/spamassassin/local.cf
# How many hits before a message is considered spam.
required_hits           5.0
# Whether to change the subject of suspected spam
rewrite_subject         1
# Text to prepend to subject if rewrite_subject is used
subject_tag             *****SPAM*****
# Encapsulate spam in an attachment
report_safe             1
# Use terse version of the spam report
use_terse_report        0
# Enable the Bayes system
use_bayes               1
# Enable Bayes auto-learning
auto_learn              1
# Enable or disable network checks
skip_rbl_checks         1
use_razor2              0
use_dcc                 0
use_pyzor               0
# Mail using languages used in these country codes will not be marked
# as being possibly spam in a foreign language.
ok_languages            all
# Mail using locales used in these country codes will not be marked
# as being possibly spam in a foreign language.
ok_locales              all

4、启动spamassassin
# service spamassassin start

MailScanner设定
1修改MailScanner.conf
# vi /etc/MailScanner/MailScanner.conf
Run As User = postfix
Run As Group = postfix
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
MTA = postfix
Virus Scanners = f-prot
Always Include SpamAssassin Report = yes
Use SpamAssassin = yes
Required SpamAssassin Score = 4
SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin
SpamAssassin Install Prefix = /usr/bin
SpamAssassin Local Rules Dir = /etc/MailScanner

2、修改 postfix支持mailscanner
# vi /etc/postfix/main.cf
变更以下的值
header_checks = regexp:/etc/postfix/header_checks
# vi /etc/postfix/header_checks
/^Received:/ HOLD
注意, 在 / 之前不可以有空白!

3、变更目录权限
# chown postfix.postfix /var/spool/MailScanner/incoming
# chown postfix.postfix /var/spool/MailScanner/quarantine
停止postfix执行、启动MailScanner
# service postfix stop
# chkconfig postfix off
# service MailScanner start
设定MailScanner,当MTA = postfix时,会自己启动postfix,如有设定启动postfix的请先将它停掉
4、定期更新病毒定义文件
# crontab -e
0 4 * * * /usr/local/f-prot/tools/check-updates.pl
并将原本在/etc/cron.hourly/update_virus_scanners 删除掉

测试SpamAssassin
发一封邮件带如下内容,接收后,标题应该带有标记:
XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X

这样,我们就已经搭建起一个基本的邮件系统。

论坛徽章:
0
2 [报告]
发表于 2007-06-22 13:01 |只看该作者
自顶一个!!

论坛徽章:
0
3 [报告]
发表于 2007-06-22 14:58 |只看该作者
垃圾邮件过滤怎么样?好用吗?

论坛徽章:
0
4 [报告]
发表于 2007-06-24 13:14 |只看该作者
还行,谁用谁知道。

论坛徽章:
0
5 [报告]
发表于 2007-06-25 16:16 |只看该作者
哈哈     谁用谁知道啊!


请问楼主,这样设置好后,客户端要不是必须要设置smtp密码才可以用这个mta?  我认为是。但是我自己做的和这个差不多,只是不设smtp的密码也可以用此mta。你说会是什么原因呢?

[ 本帖最后由 niul_work 于 2007-6-25 16:39 编辑 ]

论坛徽章:
0
6 [报告]
发表于 2007-06-26 09:55 |只看该作者
设置postfix启用SMTP认证,客户端是必须要设置smtp密码才可以用这个mta.

论坛徽章:
0
7 [报告]
发表于 2007-06-26 16:41 |只看该作者
我想用saslauthd做认证,只允许通过认证的用户发邮件,但是不成功,不认证也可以使用这个mta,不知道是怎么回事,清帮忙指点一下。谢谢。

vi /etc/postfix/main.cf

smtpd_sasl_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_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


vi /usr/lib/sasl2/smtpd.conf
log_level: 3
pwcheck_method: saslauthd
mech_list:  LOGIN PLAIN

vi /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 to use.
MECH=shadow

# Additional flags to pass to saslauthd on the command line.  See saslauthd(
# for the list of accepted flags.
#FLAGS=sasldb


我的是这样设置的,帮我看一下那里有问题呢?

论坛徽章:
0
8 [报告]
发表于 2007-06-27 08:13 |只看该作者
楼主我按你的教程只做了 Postfix+CyrusSASL+dovecot 这三个的配置,在FOXMAIL里收邮件,不管收件还是发件都不能用
下面是LOG内容,我用0921帐号测试,而且既使我是输错了密码也没有任何提示~~

Jun 26 22:09:46 myserver dovecot: pop3-login: Login: user=<0921>, method=PLAIN
, rip=::ffff:192.168.2.5, lip=::ffff:192.168.2.200
Jun 26 22:09:46 myserver dovecot: POP3(0921): Disconnected: Logged out top=0/0
, retr=0/0, del=0/0, size=0

[ 本帖最后由 liantianji 于 2007-6-27 08:14 编辑 ]

论坛徽章:
0
9 [报告]
发表于 2007-06-27 09:50 |只看该作者

zqli大哥,帮我看看我回的贴

发表于: 2007-6-26 22:10    主题:   [编辑]  [引用]  [投诉] [快速回复]  


--------------------------------------------------------------------------------




QUOTE:
原帖由 zqli 于 2007-6-26 16:21 发表
/var/mailbox的权限问题
看看该目录的权限是属于谁的?
建立/var/mailbox并设置权限


# mkdir /var/mailbox  
# chown -R vmail:vmail /var/mailbox
# chmod -R ug+rwx,o-rwx /var/mailbox

论坛徽章:
0
10 [报告]
发表于 2007-06-27 11:15 |只看该作者
按楼主的方法做了,telnet  本机ip 110 一切OK!telnet  本机ip 25 提示: telnet 172.16.16.205 25
Trying 172.16.16.205...
telnet: connect to address 172.16.16.205: Connection refused
telnet: Unable to connect to remote host: Connection refused

telnet localhost 25 没问题!也就是25好端口只能在本机使用!我只是做个内部邮件系统,不知为何呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP