问题描述:
在系统安装完毕后,通常我们只需按照缺省配置启动sendmail邮件服务就可以用mail,outlook,foxmail等常用工具收发邮件了。
简单操作如下:
# startsrc -s sendmail -a “-bd -q30m” (启动邮件服务后台进程)
# vi /etc/inetd.conf, (uncomment the line)
pop3 stream tcp nowait root /usr/sbin/pop3d pop3d
# refresh -s inted (刷新超级守护进程,允许pop3客户端连接)
但其缺省配置存在一个隐患就是,它允许任何主机和用户向其发信,但我们知道在Internet上存在着众多莫名其妙的垃圾邮件,它们占据宝贵的网络带宽,妨害邮件服务器的正常工作。很多邮件服务器由于疲于应付来自四面八方的垃圾邮件,不能为我们的工作生活带来积极有效的帮助,那么面对这些垃圾邮件我们是否手足无措呢?我们如何处理这种情况呢?
解决方案:
AIX系统为我们提供了灵活的方式去修改sendmail的特性以实现其强大丰富的功能,下面我们举例说明其中的anti-spam功能。
首先我们要确认系统中存在下列文件集:
bos.adt.base & bos.net.tcp.adt & bos.net.nis.server
AIX 将产生定制sendmail配置文件的工具和宏放在/usr/samples/tcpip/sendmail/cf
具体操作步骤如下:
#cd /usr/samples/tcpip/sendmail/cf 这里有我们需要的文件aixsample.mc. 它包含我们需要定制的sendmail特性
#cp aixsample.mc anti-spam.mc 创建它的一份拷贝
#vi anti-spam.mc divert(0)dnl
OSTYPE(aix43)dnl
FEATURE(genericstable)dnl
FEATURE(mailertable)dnl
FEATURE(virtusertable)dnl
FEATURE(domaintable)dnl
FEATURE(allmasquerade)dnl
FEATURE(promiscuous_relay)dnl
FEATURE(accept_unresolvable_domains)dnl
FEATURE(accept_unqualified_senders)dnl
DOMAIN(generic)dnl
MAILER(local)dnl
MAILER(smtp)dnl
MAILER(uucp)
编辑修改后如下:
#more anti-spam.mc -------------------------------------------------------------------------
divert(0)dnl
OSTYPE(aixsample)dnl
FEATURE(allmasquerade)dnl
FEATURE(`access_db', `dbm /etc/mail/access')dnl
DOMAIN(generic)dnl
MAILER(local)dnl
MAILER(smtp)dnl -------------------------------------------------------------------------
注意:在anti-spam.mc中,注释是不起作用的,所以不需要的feature 一定要删除,否则在生成sendmail配置文件时会出错。
如果你还需要生成包含其他特性的sendmail.cf可以参考
http://www.sendmail.org/m4/features.html 下面我们要创建sendmail.cf
#cd /usr/samples/tcpip/sendmail/cf #m4 ../m4/cf.m4 anti-spam.mc > ourmail.cf #mv /etc/mail/sendmail.cf /etc/mail/sendmail.cf.orig 备份原始文件
#mv ourmail.cf /etc/mail/sendmail.cf 使用新的配置文件
#vi /etc/mail/sendmail.cf Search for the following section and comment out the line as indicated below:
#Fw-o /etc/mail/sendmail.cw #more /etc/mail/sendmai.cf|grep Fw Fw-o /etc/sendmail.cw #more /etc/mail/sendmail.cw hostname #vi /etc/mail/access (写入拒绝发信的主机或者用户黑名单)
entry1...
entry2...
entry3...
举例如果你不希望rshelp.com的domain中的所有主机和一些用户给你的邮件服务器发信,那么你的配置文件看起来应该是这样。
#more /etc/mail/access rshelp.com reject
spammer@any.com reject
advertise@any.com reject
9.185.41 relay (允许网段9.185.41.0内的任何主机发信)
生成访问数据库
#makedbm /etc/mail/access /etc/mail/access 现在我们可以刷新sendmail服务进程,以使新生成的配置文件生效。
#refresh -s sendmail 我们可以查看sendmail邮件服务的状态
#lssrc -s sendmail Subsystem Group PID Status
sendmail mail 5424 active
如果邮件服务没有启动,我们需要手工运行
#startsrc -s sendmail -a "-bd -q30m" 测试:
如果我们用帐户spammer@any.com 和outlook通过sendmail服务器发送邮件时有如下报错:
因为其邮件地址在sendmail邮件服务器的配置文件/etc/mail/access中被拒绝。
注意事项:
此配置过程是以AIX 5.1为例,如果你的系统是AIX 4.3.3,应灵活应用并注意其区别
例如 5.1 的配置文件是/etc/mail/sendmail.cf & /etc/mail/aliases, 但4.3.3的配置是/etc/sendmail.cf & /etc/aliases.
备注:
在配置/etc/mail/access时有四种选项“ok. relay, reject, discard”,他们的解释如下
OK - Accept mail even if other rules in the running ruleset would reject it, for example, if the domain name is unresolvable.
RELAY - Accept mail addressed to the indicated domain or received from the indicated domain for relaying through your SMTP server. RELAY also serves as an implicit OK for the other checks.
REJECT - Reject the sender/recipient with a general purpose message.
DISCARD - Discard the message completely using the $#discard mailer. For sender addresses it indicates that you should discard anything received from the indicated domain. If it is used for recipients, it affects only the designated recipients, not the whole message.