- [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' [email protected] < /etc/hosts
- [root@rhel6 ~]# echo "postfix test again" | mail -s 'postfix_test2' [email protected]
- 查看[email protected]用戶收到的郵件
- [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 [email protected] Thu Apr 11 14:13:07 2013
- Return-Path: <[email protected]>
- X-Original-To: [email protected]
- Delivered-To: [email protected]
- Date: Thu, 11 Apr 2013 14:13:07 +0800
- To: [email protected]
- Subject: postfix_test2
- User-Agent: Heirloom mailx 12.4 7/29/08
- Content-Type: text/plain; charset=us-ascii
- From: [email protected] (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' [email protected]
- [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"