- [root@rhel6 ~]# cat /etc/postfix/main.cf | grep -v '^#' | grep -v '^$'
- myhostname = rhel6.xfcy.org //设置服务器主机名
- mydomain = xfcy.org //设置服务器域名
- myorigin = $mydomain //设置服务器外发邮件域名
- inet_interfaces = all //设置服务器监听的接口
- #inet_interfaces = localhost
- #inet_protocols = all //默认只监听IPv4
- mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain //设置服务器接收邮件域名
- relay_domains = $mydestination //指定信任的MTA网段(允许其转发邮件)
- mynetworks = 192.168.0.0/24, 127.0.0.0/8 //指定信任的MUA网段(允许其收发邮件)
- #home_mailbox = Maildir/ //指定用户邮箱目录
- alias_maps = hash:/etc/aliases //指定邮件别名的文件路径
- [root@rhel6 ~]# /etc/init.d/postfix restart
- Shutting down postfix: [ OK ]
- Starting postfix: [ OK ]
- [root@rhel6 ~]# mail -s 'postfix_test1' zyp19891128@163.com < /etc/hosts
- [root@rhel6 ~]# echo "postfix test again" | mail -s 'postfix_test2' user1@rhel6.xfcy.org
- 查看user1@rhel6.xfcy.org用户收到的邮件
- [root@rhel6 ~]# mail -u user1
- Heirloom Mail version 12.4 7/29/08. Type ? for help.
- "/var/mail/user1": 1 message 1 new
- >N 1 root Thu Apr 11 14:13 18/582 "postfix_test2"
- &
- Message 1:
- From root@xfcy.org Thu Apr 11 14:13:07 2013
- Return-Path: <root@xfcy.org>
- X-Original-To: user1@rhel6.xfcy.org
- Delivered-To: user1@rhel6.xfcy.org
- Date: Thu, 11 Apr 2013 14:13:07 +0800
- To: user1@rhel6.xfcy.org
- Subject: postfix_test2
- User-Agent: Heirloom mailx 12.4 7/29/08
- Content-Type: text/plain; charset=us-ascii
- From: root@xfcy.org (root)
- Status: R
- postfix test again
-
/etc/aliases应用:
- 1.邮件别名设置:用户user1可以接收其他用户发给user2的邮件,user2用户将收不到邮件(user2 --> user1)
- [root@rhel6 ~]# vi /etc/aliases
- user2: user1
- [root@rhel6 ~]# postalias /etc/aliases
- 2.邮件群组设置:将user1、user2、user3...组成一个组group,则发给group的邮件将转发给user1、user2、user3...
- [root@rhel6 ~]# vi /etc/aliases
- groupname: user1,user2,user3
- [root@rhel6 ~]# postalias /etc/aliases
- [root@rhel6 ~]# echo "mail group test" | mail -s 'group' groupname@rhel6.xfcy.org
- [root@rhel6 ~]# mail -u user1
- Heirloom Mail version 12.4 7/29/08. Type ? for help.
- "/var/mail/user1": 1 message
- > 1 root Mon Mar 18 22:34 19/594 "group"
- [root@rhel6 ~]# mail -u user2
- Heirloom Mail version 12.4 7/29/08. Type ? for help.
- "/var/mail/user2": 1 message 1 new
- >N 1 root Mon Mar 18 22:34 18/583 "group"
- [root@rhel6 ~]# mail -u user3
- Heirloom Mail version 12.4 7/29/08. Type ? for help.
- "/var/mail/user3": 1 message 1 new
- >N 1 root Mon Mar 18 22:34 18/583 "group"