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月前
|
NoSQL 关系型数据库 MySQL
多人同时导出 Excel 干崩服务器?怎样实现一个简单排队导出功能!
业务诉求:考虑到数据库数据日渐增多,导出会有全量数据的导出,多人同时导出可以会对服务性能造成影响,导出涉及到mysql查询的io操作,还涉及文件输入、输出流的io操作,所以对服务器的性能会影响的比较大;结合以上原因,对导出操作进行排队; 刚开始拿到这个需求,第一时间想到就是需要维护一个FIFO先进先出的队列,给定队列一个固定size,在队列里面的人进行排队进行数据导出,导出完成后立马出队列,下一个排队的人进行操作;还考虑到异步,可能还需要建个文件导出表,主要记录文件的导出情况,文件的存放地址,用户根据文件列表情况下载导出文件。
多人同时导出 Excel 干崩服务器?怎样实现一个简单排队导出功能!
|
2月前
|
弹性计算 数据安全/隐私保护
2024年阿里云雾锁王国/Enshrouded服务器搭建架设教程(保姆级)
随着游戏行业的日新月异,玩家们对游戏体验的期待也不断攀升。阿里云针对这一需求,推出了快速、便捷的游戏联机服务器一键部署方案。在本篇教程中,我们将向大家展示如何在短短的10秒钟内,利用阿里云服务器轻松搭建雾锁王国游戏服务器,为您的游戏体验增添更多流畅与顺畅。跟随我们的步骤,让您的游戏世界更加精彩!
|
2月前
|
缓存 关系型数据库 MySQL
百度搜索:蓝易云【CentOS8服务器安装MySQL报错:no match mysql-community-server】
现在,你已经成功安装了MySQL服务器并解决了"no match mysql-community-server"的报错问题。祝你使用愉快!
43 1
|
16天前
|
Linux
centos 查看服务器信息 版本cpu
centos 查看服务器信息 版本cpu
12 0
|
1月前
|
Oracle 关系型数据库 Linux
服务器Centos7 静默安装Oracle Database 12.2
服务器Centos7 静默安装Oracle Database 12.2
86 0
|
1月前
|
存储 弹性计算 Linux
阿里云ECS(CentOS镜像)安装docker
阿里云ECS(CentOS镜像)安装docker
385 0
|
1月前
|
存储 网络协议 数据可视化
如何使用Synology Drive作为文件同步服务器实现云同步Obsidian笔记
如何使用Synology Drive作为文件同步服务器实现云同步Obsidian笔记
|
2月前
|
弹性计算 Linux 数据安全/隐私保护
1分钟幻兽帕鲁社区服务器搭建架设开服教程(Linux)
1分钟幻兽帕鲁社区服务器搭建架设开服教程(Linux)玩转幻兽帕鲁服务器,幻兽帕鲁Palworld多人游戏专用服务器一键部署教程,阿里云推出新手0基础一键部署幻兽帕鲁服务器教程,傻瓜式一键部署,3分钟即可成功创建一台Palworld专属服务器,成本仅需26元,阿里云百科分享2024年新版基于阿里云搭建幻兽帕鲁服务器教程
72 3
|
2月前
|
Linux 应用服务中间件 nginx
国服浪潮服务器操作系统——KeyarchOS多容器架设体验心得
国服浪潮服务器操作系统——KeyarchOS多容器架设体验心得
56 0
|
2月前
|
弹性计算 Ubuntu Linux
帕鲁服务器多少钱?2024年幻兽帕鲁服务器搭建架设教程(保姆级)
帕鲁服务器多少钱?阿里云帕鲁服务器26.52元1个月在帕鲁的世界中,与神奇的生物共度悠闲时光是一种无与伦比的乐趣。然而,有时官方服务器的不稳定性可能会给游戏体验带来延迟和卡顿。 为了告别这些问题,部署自己的幻兽帕鲁服务器成为了一个不错的选择。通过搭建专属的游戏服务器(Dedicated Server),和小伙伴们获得一个专属的服务空间,获得顺畅流畅的游戏体验。 在本文中,我们将介绍如何使用自己的服务器来部署属于自己的幻兽帕鲁服务器,与小伙伴们共同展开一场精彩的冒险之旅。
146 0

热门文章

最新文章