您的位置:首页 > 大数据 > 人工智能

Mail服务器的搭建(3)----postfix

2011-10-03 16:43 344 查看
postfix邮件服务器的搭建

注:

Sendmail 单体设计
Postfix 模块化
Master /etc/postfix、master.conf
Smtpd
Smtp
Local (mda)
Sendmail procmail
Postfix local
Qmgr inconing active defer
安装包:
postfix-2.3.3-2.1.el5_2.i386.rpm
安装完之后编译主配置文档
主配置文档 /etc/postfix/main.conf
Postconf -n 改变配置
Postconf -d 默认配置
Master /etc/postfix/master.conf
Pickup 邮件的分拣
Cleanup 邮件的检测
Linux系统默认是安装了sendmail的,而且是默认的开机启动的,所以需要关闭sendmail
[root@ttttttttt ~]# chkconfig --list |grep sendmail
sendmail 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
[root@ttttttttt ~]# service sendmail status 查看sendmail是否正在运行
sendmail (pid 2896) 正在运行...
那么我们就得停止sendmail服务
[root@ttttttttt ~]# service sendmail stop
关闭 sm-client: [确定]
关闭 sendmail: [确定]
[root@ttttttttt ~]# chkconfig sendmail off
[root@ttttttttt ~]# netstat -tupln |grep 25
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2583/portmap
udp 0 0 0.0.0.0:36257 0.0.0.0:* 3003/avahi-daemon:
udp 0 0 0.0.0.0:111 0.0.0.0:* 2583/portmap
在/etc/目录下就形成了postfix的文件夹
为该邮件服务器搭建dns服务器
更改主机名:
[root@ttttttttt named]# vim /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=mail.sh.com
更改dns指向:
[root@ttttttttt named]# vim /etc/resolv.conf
nameserver 192.168.20.66
[root@ttttttttt named]# chkconfig named on 开机启动dns
然后重启系统
再次登录后我们试着只用postfix发送一封邮件
[root@mail ~]# telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 mail.sh.com ESMTP Postfix
ehlo mail.sh.com
250-mail.sh.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:user1@sh.com
250 2.1.0 Ok
rcpt to:user2@sh.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
subject:ok
llllhhhhhhhhh
.
250 2.0.0 Ok: queued as BBD6822A37F
quit
221 2.0.0 Bye
Connection closed by foreign host.
此时这封邮件是可以成功发出并接受的
查看postfix的配置手册
[root@mail ~]# man 5 postconf
进入编辑postfix的 主配置文件
[root@mail ~]# vim /etc/postfix/main.cf
70 myhostname = mail.sh.com 添加邮件服务器的名
77 mydomain = sh.com 添加邮件服务器的域名
107 inet_interfaces = all 启用监听所有的地址
110 #inet_interfaces = localhost 将只监听本地的禁用了
此时查看监听的端口:
root@mail ~]# netstat -tupln |grep 25
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2597/portmap
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 3898/master
udp 0 0 0.0.0.0:111 0.0.0.0:*
但是此时user1给user2发送邮件接受不倒
我们需要在
[root@mail ~]# vim /etc/postfix/main.cf
155 mydestination = $myhostname, localhost.$mydomain, localhost,$mydomain
然后重启postfix后就可以接受到了
做转发中继:(默认情况下从服务器上可以往其他服务器发,而连接的客户端不行)
再编译[root@mail ~]# vim /etc/postfix/main.cf
255 mynetworks = 192.168.20.0/24, 127.0.0.0/8
将做转发的网段添加进来然后重启postfix就可以了

做本地验证
首先启动sasl验证:
编译main.cf ,使其支持sasl
编译[root@mail sasl2]# vim /etc/postfix/main.cf
文件中添加这几行:
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes 启动sasl认证
smtpd_sasl_security_options = noanonymous 安全选项 ,不允许匿名用户
smtpd_sasl_application_name = smtpd
smtpd_recipient_restrictions =permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
中继设定
做完之后重启postfix,再用本地发邮件试试,发现只有通过认证后的才可以通过它发信,但是其他客户端却可以不通过认证就可以发信,
重新编译[root@mail sasl2]# vim /etc/postfix/main.cf
限定客户端:
smtpd_client_restrictions = permit_sasl_authenticated,reject
Xshell:\> telnet 192.168.20.66 25
Connecting to 192.168.20.66:25...
Connection established.
Escape character is '^@]'.
220 mail.sh.com ESMTP Postfix
mail from:user1@sh.com
250 2.1.0 Ok
rcpt to:user2@sh.com
554 5.7.1 <unknown[192.168.20.22]>: Client host rejected: Access denied
auth login dXNlcjFAc2guY29t
334 UGFzc3dvcmQ6
MTIz
235 2.0.0 Authentication successful
次时postfix邮件服务器我们就配置完成了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息