Chinaunix首页 | 论坛 | 博客
  • 博客访问: 351330
  • 博文数量: 80
  • 博客积分: 1750
  • 博客等级: 上尉
  • 技术积分: 1380
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-13 11:35
文章分类
文章存档

2014年(3)

2013年(1)

2012年(54)

2011年(22)

分类: LINUX

2012-03-24 14:20:54

RHEL6.0 简单(smtp)邮件服务器搭建

系统环境:rhel6.0-x86_64
dns server:192.168.0.44
mail server:192.168.0.5
client host: 192.168.0.6
smtp server:192.168.0.7(转发邮件)

在192.168.0.44配置DNS服务器
安装dns软件 yum install bind bind-chroot bind-utils bind-libs -y
vim /etc/named.conf
# listen-on port 53 { 127.0.0.1; };
# allow-query { localhost; };

zone "." IN {


type hint;
file "named.ca";
};

zone "example.com" IN {

type master;
file "example.com.zone";
};

配置域名正向解析文件

cp /var/named/named.localhost /var/named/example.com.zone -p

chown named.namd /var/namd/example.com.zone

vim /var/named/example.com.zone

$TTL 1D

@ IN SOA @ root. (

                                0 ; serial

                                1D ; refresh

                                1H ; retry

                                1W ; expire

                                3H ) ; minimum

                    NS    @

                     A     192.168.0.44

server5       A      192.168.0.5

mail        CNAME     server5

server6       A     192.168.0.6

client     CNAME      server6

server7      A      192.168.0.7

smtp     CNAME      server7

example.com. IN MX 10 mail.example.com.

~

example.comDNSMX记录必须指向邮件服务器mail.example.com

****注意域后面的点****

启动DNS server

/etc/init.d/named start

若有没有报任何错,则文件无语法错误,可以用dig进行测试,若dig成功的解析出ipdns配置成功

开始邮件服务器的搭建

mail server192.168.0.5主机上配置

postfix ----> 邮件传输代理软件

安装接受邮件的软件dovecotyum install dovecot postfix -y


postconf -e inet_interfaces = all

postconf -e mydestination = example.com

postconf -e myorigin = example.com

postconf -e relayhost = stmp.example.com

}


重启服务

/etc/init.d/postfix restart

/etc/init.d/dovecot restart



mydestination指定mail server接收的邮件的域,必须是以***@example.com结尾的邮件接收,其余的全部拒绝接收(注意红的字体部分的域)

编辑/etc/postfix/main.cf文件通过postconf -e ##=$$$$部分指定的内容将会覆盖或是改变文件里面##原有的内容



client host在192.168.0.6主机上配置
yum install postifx -y

编辑文件/etc/postfix/main.cf

postconf -e inet_interfaces = localhost

postconf -e myorigin = example.com

postconf -e “local_transport = error:local delivery disabled ”

postconf -e relayhost = smtp.example.com

重启服务  /etc/init.d/postfix restart


smtp server在192.168.0.7主机上配置

yum install postfix -y


编辑文件/etc/postfix/main.cf

postconf -e inet_interfaces = all

postconf -e myorigin = example.com

postconf -e “local_transport = error:local delivery disabled”

重启服务 /etc/inti.d/postfix restart


开始收发邮件的测试


client(server6)主机发送邮件,假设mail server有一个hazeline用户

client发送邮件:mail hazeline

[root@client ~]# mail hazeline

Subject: hello

helloworld

helloworld

EOT ----> ctrl+d


root@server6 ~]# tail /var/log/maillog

Mar 23 23:51:38 server6 postfix/pickup[2338]: 7FA85424D2: uid=0 from=

Mar 23 23:51:38 server6 postfix/cleanup[2377]: 7FA85424D2: messageid=<20120323155138.7FA85424D2@server6.example.com>

Mar 23 23:51:38 server6 postfix/qmgr[2069]: 7FA85424D2: from=, size=450, nrcpt=1 (queue active)

Mar 23 23:51:48 server6 postfix/smtp[2380]: 7FA85424D2: to=, orig_to=, relay=smtp.example.com[192.168.0.7]:25, delay=10, delays=0.12/0.02/10/0.18, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as D230C402C9)

Mar 23 23:51:48 server6 postfix/qmgr[2069]: 7FA85424D2: removed


mail server(server5)

查收hazeline的邮件

[root@server5 ~]# cat /var/spool/mail/hazeline

From root@example.com Wed Mar 21 05:42:01 2012

Return-Path:

X-Original-To: hazeline@example.com

Delivered-To: hazeline@example.com

Received: from server7.example.com (unknown [192.168.0.7])

              by server5.example.com (Postfix) with ESMTP id 30C2241CD5

               for ; Wed, 21 Mar 2012 05:42:01 +0800 (CST)

Received: from server6.example.com (unknown [192.168.0.6])

               by server7.example.com (Postfix) with ESMTP id 27CE8402C9

               for ; Wed, 21 Mar 2012 05:40:40 +0800 (CST)

Received: by server6.example.com (Postfix, from userid 0)

               id D087E424D2; Fri, 23 Mar 2012 23:42:03 +0800 (CST)

Date: Fri, 23 Mar 2012 23:42:03 +0800

To: ----> 接收邮件的用户

Subject: hello ----> 邮件标题

User-Agent: Heirloom mailx 12.4 7/29/08

MIME-Version: 1.0

Content-Type: text/plain; charset=us-ascii

Content-Transfer-Encoding: 7bit

Message-Id: <20120323154203.D087E424D2@server6.example.com>

From: root@example.com (root)

helloworld

helloworld ----> 邮件内容


....GOOD LUCK!




阅读(2575) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~