Postfix Relay to Exchange Server 2010

有时候公司在基于安全性的情况下需要将公司邮件服务器中的邮件通过另一台外围边缘邮件服务器发送出去,而不是直接用公司内部邮件服务器

这里采用的是Centos 6.3postfix通过中继转发到Exchange发送邮件,这方面的资料在网上很少,不过很多是做Postfix Relay to Gmail,将Gmail换成是Exchange原理是一样的。

此次试验只是做到postfix relay to exchange发送邮件,很多认证、中继限制等功能还未添加,避免不了会有被当做中继邮件服务器的可能(造成的后果就是被用来做中继邮件服务器发送大量的垃圾邮件,因此被国际邮件ISP将你的服务器IP列入黑名单)。具体优化后期再进行添加。

1.实验环境:

Postfix已安装完成且可用

Exchange邮件服务器已安装完成且可用

 

2.配置Postfix

添加如下几行到postfix配置文件中

1.# vi /etc/postfix/main.cf
2.relayhost = mail.example.com:25
3.smtp_sasl_auth_enable = yes
4.smtp_sasl_password_maps =hash:/etc/postfix/sasl_passwd
5.smtp_sasl_security_options = noanonymous

设置sasl_passwd文件

1.# vi /etc/postfix/sasl_passwd

添加Exchange SMTP服务器域名、端口、认证账号密码

1.[mail.example.com]:25 wemux@example.com:password

修改sasl_passwd权限

1.# chmod 400 /etc/postfix/sasl_passwd
2.# postmap /etc/postfix/sasl_passwd     #生成sasl_passwd.db文件

至此postfix这边的工作就做完了

 

3.设置Exchange服务器

新建接受连接器接受postfix发来的中继转发请求

设置接受连接器名称以及接受连接器类型

设置接受从postfix server发送来的邮件

创建完成之后对连接器做进一步设置,打开postfix relay properties 切换至authentication选项卡,确认勾选以下两项。

勾选“Exchange Servers”复选框

至此,Exchange这边的设置也做完了,接下来的就是测试

 

4.测试

使用postfix发送邮件

1.# echo "this is test mail!" | mail -s "test mail title" 457922962@<a href="http://www.it165.net/qq/" target="_blank" class="keylink">qq</a>.com

查看实时日志的情况

1.# tail -f /var/log/maillog
2.May 21 11:18:51 Mail01 postfix/pickup[30090]: 39392E023D: uid=0 from=<root>
3.May 21 11:18:51 Mail01 postfix/cleanup[30105]: 39392E023D:message-id=<20130521031851.39392E023D@mail.example.com>
4.May 21 11:18:51 Mail01 postfix/qmgr[30091]: 39392E023D: from=<root@postfix.com>,size=467, nrcpt=1 (queue active)
5.May 21 11:18:51 Mail01 postfix/smtp[30110]: warning: mail.example.com[202.175.86.40]:25 offerednull AUTH mechanism list
6.May 21 11:19:21 Mail01 postfix/smtp[30110]: 39392E023D: to=<457922962@<a href="http://www.it165.net/qq/" target="_blank"class="keylink">qq</a>.com>,relay=mail.example.com[202.105.***.***]:25, delay=31,delays=0.03/0.02/0.08/30, dsn=2.6.0, status=sent (250 2.6.0<20130521031851.39392E023D@mail.example.com> [InternalId=297745]Queued mail fordelivery)
7.May 21 11:19:21 Mail01 postfix/qmgr[30091]: 39392E023D: removed

可以查看到邮件已经从postfix发出去

 

Exchange上查看邮件发送记录

再到我的个人邮箱查看收信情况

从postfix中继转发到exchange这个问题我也研究了有一段时间,现在终于搞定了,之后就是有关优化这方面的问题。

分享到