CentOS 6.4下Postfix邮件服务安装和基本配置
CentOS 5.5下邮件服务器Postfix安装
搭建Red Hat Enterprise Linux 5.4的Postfix邮件服务器
实验需求:为公司搭建一台能够收信和发信的邮件服务器(192.168.100.1),为员工提供服务,公司域名为linuxidc.com.
一.修改DNS服务器(192.168.100.2)上mx邮件交换记录,确保客户机能解析邮件服务器地址
1.修改DNS区域文件
# vim /var/named/linuxidc.com.zone
$TTL 3H
@ IN SOA linuxidc.com. root.linuxidc.com. (
2014042601; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns1.linuxidc.com.
IN MX 10 mail.linuxidc.com.
dns1 IN A 192.168.100.2
mail IN A 192.168.100.1
……
2.重启服务
# service named restart
3.客户机测试能否解析
# host -t mx linuxidc.com 192.168.100.2 //查询目标域的MX记录
Using domain server:
Name: 192.168.100.2
Address: 192.168.100.2#53
Aliases:
linuxidc.com mail is handled by 10 mail.linuxidc.com.
# host mail.linuxidc.com 192.168.100.2 //查看邮件服务器的解析结果
Using domain server:
Name: 192.168.100.2
Address: 192.168.100.2#53
Aliases:
mail.linuxidc.com has address 192.168.100.1
二.搭建postfix发信服务器
1.安装软件包
# yum -y install postfix
2.修改主配置文件
[root@mail ~]# cd /etc/postfix/
# postconf -n > tmp.txt //导出非默认配置
# mv main.cf main.cf.bak
# mv tmp.txt main.cf
# vim main.cf
...
9 #inet_interfaces = localhost //监听端口
22 myhostname = mail.linuxidc.com //邮件服务器主机名
23 mydomain = linuxidc.com //邮件服务器所在区域
24 myorigin = $mydomain //发件人DNS后缀
25 mydestination = $mydomain //指定Postfix允许处理的邮件
26 home_mailbox = Maildir/ //邮箱类型
3、检查语法启动服务
# postfix check
# service postfix start
# chkconfig postfix on
# netstat -tulnp | grep :25 //发信使用SMTP协议
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 3564/master
tcp 0 0 :::25 :::* LISTEN 3564/master
4.新建邮箱用户 //邮件用户默认为系统用户
# useradd damao
# echo 123456| passwd --stdin damao
# useradd tom
# echo 123456| passwd --stdin tom
5.测试发信功能
# telnet mail.linuxidc.com 25
Trying 192.168.100.1...
Connected to mail.linuxidc.com.
Escape character is '^]'.
220 mail.linuxidc.com ESMTP Postfix
helo localhost //宣告客户端
250 mail.linuxidc.com
mail from:damao@linuxidc.com //邮件发件人
250 2.1.0 Ok
rcpt to:tom@linuxidc.com //邮件收件人
250 2.1.5 Ok
data //邮件正文
354 End data with <CR><LF>.<CR><LF>
subject:Test mail //邮件主题
hello,tom //邮件内容
. //独立.表示邮件结束
250 2.0.0 Ok: queued as 9B6463FD97
quit //退出
221 2.0.0 Bye
Connection closed by foreign host.
6.验证邮件是否发送成功
# ls /home/tom/Maildir/new/
1398492202.V803Ibf420M185454.mail.linuxidc.com
# cat /home/tom/Maildir/new/1398492202.V803Ibf420M185454.mail.linuxidc.com
Return-Path: <damao@linuxidc.com>
X-Original-To: tom@linuxidc.com
Delivered-To: tom@linuxidc.com
Received: from localhost (unknown [192.168.100.1])
by mail.linuxidc.com (Postfix) with SMTP id 9B6463FD97
for <tom@linuxidc.com>; Fri, 25 Apr 2014 23:00:32 -0700 (PDT)
subject:Test mail
Message-Id: <20140426060137.9B6463FD97@mail.linuxidc.com>
Date: Fri, 25 Apr 2014 23:00:32 -0700 (PDT)
From: damao@linuxidc.com
To: undisclosed-recipients:;