|
需要安装的软件包:postfix
环境为:redhat 6.1 32bit
主配置文件 /etc/postfix/main.cf
运行参数配置/etc/postfix/master.cf
访问控制文件 /etc/postfix/access
别名数据库文件/etc/aliases
虚拟别名域库文件/etc/postfix/virtual
这次实验实现了收发邮件的基本功能,还有指定别名实现群发。 具体过程如下:
[iyunv@localhost etc]# cd /var/named/chroot/var/named/
[iyunv@localhost named]# ls
1.zone data named.ca named.localhost slaves
chroot dynamic named.empty named.loopback
[iyunv@localhost named]# vim 1.zone#先修改DNS域名服务器,使之能够解析邮件服务器地址
$TTL 1D
@ IN SOA example.com. root. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS chen
@ MX 10 mail#@ 指在本域内,即example.com,MX为邮件服务器解析,10优先级,mail为邮件服务器的hostname
mail A 192.169.1.100#解析到自己
example.com. A 192.169.1.100
station1 A 192.169.1.100
www A 192.169.1.100
chen A 192.169.1.100
ftp CNAME www
[iyunv@localhost named]# service named restart
停止 named:..^C
[iyunv@localhost named]# ps aux|grep named
root 6205 0.0 0.0 103244 860 pts/12 S+ 11:04 0:00 grep named
named 30927 0.0 2.9 235964 30508 ? Ssl 01:36 0:05 /usr/sbin/named -u named -t /var/named/chroot
[iyunv@localhost named]# kill -9 30927
[iyunv@localhost named]# service named start
启动 named: [确定]
[iyunv@localhost named]# nslookup www.example.com
Server:192.169.1.100
Address:192.169.1.100#53
Name:www.example.com
Address: 192.169.1.100
[iyunv@localhost named]# nslookup mail.example.com#可以正常解析
Server:192.169.1.100
Address:192.169.1.100#53
Name:mail.example.com
Address: 192.169.1.100
[iyunv@localhost named]# hostname
localhost.localdomain
[iyunv@localhost named]# hostname mail.example.com#修改hostname
[iyunv@localhost named]# vim /etc/sysconfig/network#写入配置文件
NETWORKING=yes
HOSTNAME=mail.example.com
[iyunv@localhost named]# yum -y install postfix#安装postfix包
Loaded plugins: refresh-packagekit, rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package postfix.i686 2:2.6.6-2.2.el6_1 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Updating:
postfix i686 2:2.6.6-2.2.el6_1 rhel-source 2.0 M
Transaction Summary
================================================================================
Install 0 Package(s)
Upgrade 1 Package(s)
Total download size: 2.0 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : 2:postfix-2.6.6-2.2.el6_1.i686 1/2
Cleanup : 2:postfix-2.6.6-2.el6.i686 2/2
Updated:
postfix.i686 2:2.6.6-2.2.el6_1
Complete!
[iyunv@localhost named]# cd /etc/postfix/
[iyunv@localhost postfix]# ls
access generic main.cf relocated virtual
canonical header_checks master.cf transport
[iyunv@localhost postfix]# vim main.cf#修改主配置文件
#主要配置如下几个地方
myhostname = mail.example.com#本机主机名
mydomain = example.com#域名
myorigin = $mydomain#设置由本机寄出去的邮件所使用的域名或主机名
inet_interfaces = all#postfix所监听的网络
mydestination = $myhostname, localhost.$mydomain, localhost, example.com#设置可接受邮件的主机名和域名
mynetworks = 192.169.1.0/24#设置在什么网络内收发邮件
relay_domains = $mydestination#设置在什么网域内收发邮件
[iyunv@localhost postfix]# service postfix restart
关闭 postfix: [确定]
启动 postfix: [确定]
[iyunv@localhost postfix]# id user1
uid=502(user1) gid=502(user1) 组=502(user1)
[iyunv@localhost postfix]# mail user1
Subject: hello user1
nihao
EOT
[iyunv@localhost postfix]# su - user1
[user1@mail ~]$ mail
Heirloom Mail version 12.4 7/29/08. Type ? for help.
"/var/spool/mail/user1": 1 message 1 new
>N 1 root Mon Aug 13 11:14 18/551 "hello user1"
& 1
Message 1:
From root@example.com Mon Aug 13 11:14:57 2012
Return-Path: <root@example.com>
X-Original-To: user1
Delivered-To: user1@example.com
Date: Mon, 13 Aug 2012 11:14:57 +0800
To: user1@example.com
Subject: hello user1
User-Agent: Heirloom mailx 12.4 7/29/08
Content-Type: text/plain; charset=us-ascii
From: root@example.com (root)
Status: R
nihao
& quit
Held 1 message in /var/spool/mail/user1
[user1@mail ~]$
------------------群发,指定别名-------------------
[iyunv@localhost postfix]# pwd
/etc/postfix
[iyunv@localhost postfix]# ls
access generic main.cf relocated virtual
canonical header_checks master.cf transport
[iyunv@localhost postfix]# vim main.cf
#指定别名数据库,第386和397行要打开,指定别名数据库
385 #alias_maps = dbm:/etc/aliases
386 alias_maps = hash:/etc/aliases
387 #alias_maps = hash:/etc/aliases, nis:mail.aliases
388 #alias_maps = netinfo:/aliases
389
390 # The alias_database parameter specifies the alias database(s) that
391 # are built with "newaliases" or "sendmail -bi". This is a separate
392 # configuration parameter, because alias_maps (see above) may specify
393 # tables that are not necessarily all under control by Postfix.
394 #
395 #alias_database = dbm:/etc/aliases
396 #alias_database = dbm:/etc/mail/aliases
397 alias_database = hash:/etc/aliases
398 #alias_database = hash:/etc/aliases, hash:/opt/majordomo/aliases
[iyunv@localhost postfix]# vim /etc/aliases
You have new mail in /var/spool/mail/root
92 # trap decode to catch security attacks
93 decode: root
94 jinpeng.chen: user1, user2#增加这行,jinpeng.chen为其他所有用户到别名
95 # Person who should get root's mail
96 #root: marc
[iyunv@localhost postfix]# newaliases#刷新别名数据库
[iyunv@localhost postfix]# mail jinpeng.chen
Subject: qunfa
hello,everyone...
.
EOT
[iyunv@localhost postfix]# su - user1
[user1@mail ~]$ mail
Heirloom Mail version 12.4 7/29/08. Type ? for help.
"/var/spool/mail/user1": 2 messages 1 new
1 root Mon Aug 13 11:14 19/562 "hello user1"
>N 2 root Mon Aug 13 11:35 18/578 "qunfa"
& 2
Message 2:
From root@example.com Mon Aug 13 11:35:36 2012
Return-Path: <root@example.com>
X-Original-To: jinpeng.chen
Delivered-To: jinpeng.chen@example.com
Date: Mon, 13 Aug 2012 11:35:36 +0800
To: jinpeng.chen@example.com
Subject: qunfa
User-Agent: Heirloom mailx 12.4 7/29/08
Content-Type: text/plain; charset=us-ascii
From: root@example.com (root)
Status: R
hello,everyone...
& quit
Held 2 messages in /var/spool/mail/user1
[user1@mail ~]$ exit
logout
[iyunv@localhost postfix]# su - user2
[user2@mail ~]$ mail
Heirloom Mail version 12.4 7/29/08. Type ? for help.
"/var/spool/mail/user2": 1 message 1 new
>N 1 root Mon Aug 13 11:35 18/578 "qunfa"
& 1
Message 1:
From root@example.com Mon Aug 13 11:35:37 2012
Return-Path: <root@example.com>
X-Original-To: jinpeng.chen
Delivered-To: jinpeng.chen@example.com
Date: Mon, 13 Aug 2012 11:35:36 +0800
To: jinpeng.chen@example.com
Subject: qunfa
User-Agent: Heirloom mailx 12.4 7/29/08
Content-Type: text/plain; charset=us-ascii
From: root@example.com (root)
Status: R
hello,everyone...
& quit
Held 1 message in /var/spool/mail/user2
[user2@mail ~]$ |
|