CentOS4.4下邮件服务器架设笔记之邮件网关功能实现

简介:
1.通过参考以上两篇文章:
        我们基本上实现了邮件收发,以及对垃圾邮件过滤的功能,但是目前面对企业来说,用microsoft exchange的比较多,我的想法,就是想要把这台邮件服务器的变成邮件网关,所有流进内部邮件服务器的邮件先经过MX GATEWAY扫描后,再往后面丢;虽然目前市面上很多这样功能的产品,但是价格却是一笔投资,但是LINUX却能容易做到;我在此写BLOG,把自己测试的情况与大家交流,相信对初学者是一个总结;
        包括此篇文章的总结,也是花费我了将近一个月的时间抽空测试总结出来的,我希望以此作为抛砖引玉的功能,让大家把自己更好的总结给贡献出来!我自己是一个LINUX初学者,我想通过此平台认识更多的朋友,大家互相交流一下! QQ:418027712
 
2.转入正题:
首先介绍下我的内网测试环境:
a.参考上面两篇文档:分别架设服务器A,其IP地址:10.6.6.111;
b.新安装一台邮件服务器B,只包含(postfix+dovecot),没有垃圾过滤功能;来替代现实环境的exchange服务器,因为安装linux邮件服务器比microsoft平台的exchange快,简单,更重要的,找个古董机器都能装;
c.两台机器都是同一个域,centos.eb.cn
A机器名:mail.centos.eb.cn         B机器名:mail1.cenots.eb.cn
3.开始配置:
a.配置邮件网关机器A,修改通过传输表实现转发;
即当邮件发给A机器时,A全部转发给B机器;
[root@mail ~]# cd /etc/postfix
[root@mail postfix]# vi main.cf
增加
transport_maps = hash:/etc/postfix/transport
然后保存退出,并编辑:
[root@mail postfix]# vi transport
增加
centos.eb.cn  relay:[10.6.6.120]
保存退出后,执行:
[root@mail postfix]# postmap /etc/postfix/transport
[root@mail postfix]# postfix reload
postfix/postfix-script: refreshing the Postfix mail system
b.配置MailScanner.conf实现,当A机器对收到的外部邮件判断垃圾邮件时,丢到B机器的指定帐户 [email]spam@centos.eb.cn[/email];
[root@mail postfix]# vi /etc/MailScanner/MailScanner.conf
#Spam Actions = deliver header "X-Spam-Status: Yes"      #将此行的配置注释掉;
Spam Actions = forward 
[email]spam@centos.eb.cn[/email]     #转发指定账户配置
#High Scoring Spam Actions = deliver header "X-Spam-Status: Yes"   #将此行的配置注释掉;
High Scoring Spam Actions = forward [email]spam@centos.eb.cn[/email]  #转发指定账户配置
 
重新启动一下MailScanner
[root@mail postfix]# service MailScanner restart
Shutting down MailScanner daemons:
         MailScanner:                                      [  OK  ]
         incoming postfix:                                 [  OK  ]
         outgoing postfix:                                 [  OK  ]
Waiting for MailScanner to die gracefully ....................................................................... dead.
Starting MailScanner daemons:
         incoming postfix:                                 [  OK  ]
         outgoing postfix:                                 [  OK  ]
         MailScanner:                                      [  OK  ]
[root@mail postfix]#
其实MailScanner在判定为垃圾邮件处理有多种方式,见如下参数;
# This is just like the "Spam Actions" option above, except that it applies
# to messages that are *NOT* spam.
#    deliver                 - deliver the message as normal
#    delete                  - delete the message
#    store                   - store the message in the (non-spam) quarantine
#    store-nonmcp            - store the message in the non-MCP quarantine
#    store-mcp               - store the message in the MCP quarantine
#    store-nonspam           - store the message in the non-spam quarantine
#    store-spam              - store the message in the spam quarantine
#    forward 
[email]user@domain.com[/email] - forward a copy of the message to [email]user@domain.com[/email]
#    striphtml               - convert all in-line HTML content to plain text
#    header "name: value"    - Add the header
#                                name: value
#                              to the message. name must not contain any spaces.
#    custom(parameter)       - Call the CustomAction function in /usr/lib/Mail-
#                              Scanner/MailScanner/CustomFunctions/CustomAction
#                              .pm with the 'parameter' passed in. This can be
#                              used to implement any custom action you require.
新建一个账户,收集垃圾邮件;
[root@mail postfix]# ssh root@10.6.6.120
mailto:root@10.6.6.120 password:
[root@mail1 ~]# adduser spam -s /sbin/nologin
Changing password for user spam.
New UNIX password:
BAD PASSWORD: it is too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
 
 
4.开始测试,分别发送一正常与垃圾信给 [email]leeki.yan@centos.eb.cn[/email]
a.首先从 [email]leeki.yan@trinet.com.cn[/email]测试一封正常信到 [email]leeki.yan@centos.eb.cn[/email],理论上正常信,经过A机器扫描后,会往后面B机器relay,并且寄给 [email]leeki.yan@centos.eb.cn[/email],查看日志如下:
Sep 30 16:38:36 mail postfix/smtpd[8637]: connect from unknown[10.0.0.1]
Sep 30 16:38:36 mail postfix/smtpd[8637]: 8002B170301: client=unknown[10.0.0.1]
Sep 30 16:38:36 mail postfix/cleanup[8639]: 8002B170301: hold: header Received: from mail.trinet.com.cn (unknown [10.0.0.1])??by mail.centos.eb.cn (Postfix) with ESMTP id 8002B170301??for <[email]leeki.yan@centos.eb.cn[/email]>; Sun, 30 Sep 2007 16:38:36 +0800 (CST) from unknown[10.0.0.1]; from=<[email]leeki.yan@trinet.com.cn[/email]> to=<[email]leeki.yan@centos.eb.cn[/email]> proto=ESMTP helo=<mail.trinet.com.cn>
Sep 30 16:38:36 mail postfix/cleanup[8639]: 8002B170301: hold: header Received: from triumphweihu ([10.0.0.1]) by mail.trinet.com.cn with Microsoft SMTPSVC(5.0.2195.6713);?? Sun, 30 Sep 2007 16:47:36 +0800 from unknown[10.0.0.1]; from=<[email]leeki.yan@trinet.com.cn[/email]> to=<[email]leeki.yan@centos.eb.cn[/email]> proto=ESMTP helo=<mail.trinet.com.cn>
Sep 30 16:38:36 mail postfix/cleanup[8639]: 8002B170301: message-id=<00da01c8033d$5e55aa60$de04040a@triumphweihu>
Sep 30 16:38:36 mail postfix/smtpd[8637]: disconnect from unknown[10.0.0.1]
Sep 30 16:38:38 mail MailScanner[8125]: New Batch: Scanning 1 messages, 2650 bytes
Sep 30 16:38:42 mail MailScanner[8125]: Virus and Content Scanning: Starting
Sep 30 16:38:53 mail MailScanner[8125]: Requeue: 8002B170301.BC8D5 to 52652170302
Sep 30 16:38:53 mail MailScanner[8125]: Uninfected: Delivered 1 messages
Sep 30 16:38:53 mail postfix/qmgr[8107]: 52652170302: from=<[email]leeki.yan@trinet.com.cn[/email]>, size=2872, nrcpt=1 (queue active)
Sep 30 16:38:53 mail postfix/smtp[8647]: 52652170302: to=<[email]leeki.yan@centos.eb.cn[/email]>, relay=10.6.6.120[10.6.6.120], delay=17, status=sent (250 Ok: queued as 122AF2206E0)
Sep 30 16:38:53 mail postfix/qmgr[8107]: 52652170302: removed
 
见上面红色字体部分,说明已经往后B机器relay成功了!
 
b.从 [email]418027712@qq.com[/email]测试一封垃圾信到 [email]leeki.yan@centos.eb.cn[/email],理论上垃圾信,经过A机器扫描后,会往后面B机器relay,寄给 [email]spam@centos.eb.cn[/email],查看日志如下:
Sep 30 17:05:01 mail postfix/smtpd[3496]: connect from smtpbg12.qq.com[58.60.13.110]
Sep 30 17:05:01 mail postfix/smtpd[3496]: C9D89170301: client=smtpbg12.qq.com[58.60.13.110]
Sep 30 17:05:01 mail postfix/cleanup[3504]: C9D89170301: hold: header Received: from smtpbg12.qq.com (smtpbg12.qq.com [58.60.13.110])??by mail.centos.eb.cn (Postfix) with ESMTP id C9D89170301??for < [email]leeki.yan@centos.eb.cn[/email]>; Sun, 30 Sep 2007 17:05:01 +0800 (CST) from smtpbg12.qq.com[58.60.13.110]; from=< [email]418027712@qq.com[/email]> to=< [email]leeki.yan@centos.eb.cn[/email]> proto=ESMTP helo=<smtpbg12.qq.com>
Sep 30 17:05:01 mail postfix/cleanup[3504]: C9D89170301: message-id=< [email]tencent_46D546001FA9FA1C63F8C299@qq.com[/email]>
Sep 30 17:05:01 mail postfix/smtpd[3496]: disconnect from smtpbg12.qq.com[58.60.13.110]
Sep 30 17:05:02 mail MailScanner[3341]: New Batch: Scanning 1 messages, 1614 bytes
Sep 30 17:05:36 mail MailScanner[3341]: Spam Checks: Found 1 spam messages
Sep 30 17:05:36 mail MailScanner[3341]: Virus and Content Scanning: Starting
Sep 30 17:06:20 mail MailScanner[3341]: Requeue: C9D89170301.4D561 to 1B757170304
Sep 30 17:06:20 mail MailScanner[3026]: Uninfected: Delivered 1 messages
Sep 30 17:06:20 mail postfix/qmgr[2587]: 1B757170304: from=< [email]418027712@qq.com[/email]>, size=1834, nrcpt=1 (queue active)
Sep 30 17:06:30 mail postfix/smtp[3591]: 1B757170304: to=< [email]spam@centos.eb.cn[/email] >, relay=10.6.6.120[10.6.6.120], delay=89, status=sent (250 Ok: queued as 19B222206E0)
Sep 30 17:06:30 mail postfix/qmgr[2587]: 1B757170304: removed
由面日志红色字体部分可以看出,首先检测发现邮件为垃圾邮件,然后,在往B机器relay时,投寄到 [email]spam@centos.eb.cn[/email];
 
5.测试完成!
 
 
6.2007年10月8日22时补充说明:
,但是经与jacky网友聊天得知:理论上,邮件网关配置好了后,外部发过的来的邮件到邮件网关时,是不需要查询本地用户组的,他只管往后面丢,所以我测试查找发现,要修改邮件网关的main.cf文件,找到:
#local_recipient_maps =
修改成:
local_recipient_maps = 
即把注释给取消掉,就可以!

本文转自 godoha 51CTO博客,原文链接:http://blog.51cto.com/godoha/44512 ,如需转载请自行联系原作者

相关文章
|
1月前
|
监控 Linux 应用服务中间件
centos7 部署zabbix5 踩坑笔记
centos7 部署zabbix5 踩坑笔记
|
3月前
|
弹性计算 数据安全/隐私保护
2024年阿里云雾锁王国/Enshrouded服务器搭建架设教程(保姆级)
随着游戏行业的日新月异,玩家们对游戏体验的期待也不断攀升。阿里云针对这一需求,推出了快速、便捷的游戏联机服务器一键部署方案。在本篇教程中,我们将向大家展示如何在短短的10秒钟内,利用阿里云服务器轻松搭建雾锁王国游戏服务器,为您的游戏体验增添更多流畅与顺畅。跟随我们的步骤,让您的游戏世界更加精彩!
|
1天前
基于jeecgboot的支持flowable的排它网关之后的会签功能(二)
基于jeecgboot的支持flowable的排它网关之后的会签功能(二)
|
1天前
|
前端开发
基于jeecgboot的支持flowable的排它网关之后的会签功能(一)
基于jeecgboot的支持flowable的排它网关之后的会签功能(一)
|
3天前
|
网络协议 物联网 Linux
你不能不知道的:无公网IP,SSH远程连接CentOS服务器【内网穿透】
你不能不知道的:无公网IP,SSH远程连接CentOS服务器【内网穿透】
|
4天前
|
存储 安全 网络协议
云服务器 Centos7 部署 Elasticsearch 8.0 + Kibana 8.0 指南
云服务器 Centos7 部署 Elasticsearch 8.0 + Kibana 8.0 指南
14 0
|
5天前
|
Linux 网络安全 数据库
linux centos系统搭建samba文件服务器 NetBIOS解析 (超详细)
linux centos系统搭建samba文件服务器 NetBIOS解析 (超详细)
|
16天前
|
安全 Linux 网络安全
记录_centos搭建ftp服务器
记录_centos搭建ftp服务器
13 0
|
18天前
|
运维 Apache 数据安全/隐私保护
CentOS6.5搭建SVN服务器(Apache+SVN)
CentOS6.5搭建SVN服务器(Apache+SVN)
|
1月前
|
Linux
centos 查看服务器信息 版本cpu
centos 查看服务器信息 版本cpu
20 0