郵件服務器搭建之:Postfix郵件服務器外發/郵件別名的配置

Postfix的相關目錄/命令
·    /etc/postfix             :該目錄中包括Postfix服務的主配置文件、各類腳本、查詢表等。
·    /usr/libexec/postfix/ :該目錄中包括Postfix服務的各個服務器程序文件。
·    /var/spool/postfix/    :該目錄中包括Postfix服務的郵件隊列相關的子目錄。
·    /usr/sbin/post*        :該目錄中包括Postfix服務的管理工具程序。其中,主要的幾個程序文件及其作用如下。
postalias               :用於設置郵件別名
       postcat                :用於查看消息隊列中郵件的內容(/var/spool/postfix/maildrop/)
postconf              :用於顯示main.cf 配置文件(-d/n 顯示默認/非默認設置)
postfix                 :用於檢查(check)、啓動(start)、停止(stop)、重啓(reload) postfix
postmap              :用於構造、修改或者查詢查詢表。
postqueue           :用於管理郵件隊列
 
Postfix的配置文件
Postfix系統最主要的配置文件包括:
·    /etc/postfix/main.cf         Postfix服務的配置文件
·    /etc/postfix/master.cf      master程序的配置文件
·    /etc/postfix/access
·    /etc/aliases                    設置郵件別名,也可設置郵件羣組
 
Postfix的日誌文件
Postfix系統的日誌文件位於“/var/log/maillog”,此文件記錄了Postfix服務器的運行狀態信息。
postfix的啓動控制
Postfix系統的啓動控制主要通過“/usr/sbin/postfix”命令進行,後面添加相應的startstopcheckreload參數即可分別啓動、停止、檢查、重載postfix服務。
 
  1. [root@rhel6 ~]# cat /etc/postfix/main.cf | grep -v '^#' | grep -v '^$'   
  2. myhostname = rhel6.xfcy.org                                     //設置服務器主機名   
  3. mydomain = xfcy.org                                             //設置服務器域名   
  4. myorigin = $mydomain                                            //設置服務器外發郵件域名   
  5. inet_interfaces = all                                           //設置服務器監聽的接口   
  6. #inet_interfaces = localhost   
  7. #inet_protocols = all                                           //默認只監聽IPv4   
  8. mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain          //設置服務器接收郵件域名   
  9. relay_domains = $mydestination                                  //指定信任的MTA網段(允許其轉發郵件)   
  10. mynetworks = 192.168.0.0/24, 127.0.0.0/8                        //指定信任的MUA網段(允許其收發郵件)   
  11. #home_mailbox = Maildir/                                        //指定用戶郵箱目錄   
  12. alias_maps = hash:/etc/aliases                                  //指定郵件別名的文件路徑   
  13.    
  14. [root@rhel6 ~]# /etc/init.d/postfix restart   
  15. Shutting down postfix:                                     [  OK  ]   
  16. Starting postfix:                                          [  OK  ]   
  17.    
  18. [root@rhel6 ~]# mail -s 'postfix_test1' [email protected] < /etc/hosts   
  19. [root@rhel6 ~]# echo "postfix test again" | mail -s 'postfix_test2' [email protected]  
  20. 查看[email protected]用戶收到的郵件
  21. [root@rhel6 ~]# mail -u user1  
  22. Heirloom Mail version 12.4 7/29/08.  Type ? for help.  
  23. "/var/mail/user1": 1 message 1 new  
  24. >N  1 root                  Thu Apr 11 14:13  18/582   "postfix_test2"  
  25. &   
  26. Message  1:  
  27. From [email protected]  Thu Apr 11 14:13:07 2013  
  28. Return-Path: <[email protected]>  
  29. X-Original-To[email protected]  
  30. Delivered-To[email protected]  
  31. Date: Thu, 11 Apr 2013 14:13:07 +0800  
  32. To[email protected]  
  33. Subject: postfix_test2  
  34. User-Agent: Heirloom mailx 12.4 7/29/08  
  35. Content-Type: text/plain; charset=us-ascii  
  36. From[email protected] (root)  
  37. Status: R  
  38.   
  39. postfix test again  
查看[email protected]用戶收到的郵件

  • /etc/aliases應用: 
  1. 1.郵件別名設置:用戶user1可以接收其他用戶發給user2的郵件,user2用戶將收不到郵件(user2 --> user1) 
  2. [root@rhel6 ~]# vi /etc/aliases 
  3. user2:          user1 
  4. [root@rhel6 ~]# postalias /etc/aliases 
  5.  
  6. 2.郵件羣組設置:將user1、user2、user3...組成一個組group,則發給group的郵件將轉發給user1、user2、user3... 
  7. [root@rhel6 ~]# vi /etc/aliases 
  8. groupname:      user1,user2,user3 
  9. [root@rhel6 ~]# postalias /etc/aliases 
  10. [root@rhel6 ~]# echo "mail group test" | mail -s 'group' [email protected] 
  11. [root@rhel6 ~]# mail -u user1 
  12. Heirloom Mail version 12.4 7/29/08.  Type ? for help. 
  13. "/var/mail/user1": 1 message 
  14. >   1 root                  Mon Mar 18 22:34  19/594   "group" 
  15. [root@rhel6 ~]# mail -u user2 
  16. Heirloom Mail version 12.4 7/29/08.  Type ? for help. 
  17. "/var/mail/user2": 1 message 1 new 
  18. >N  1 root                  Mon Mar 18 22:34  18/583   "group" 
  19. [root@rhel6 ~]# mail -u user3 
  20. Heirloom Mail version 12.4 7/29/08.  Type ? for help. 
  21. "/var/mail/user3": 1 message 1 new 
  22. >N  1 root                  Mon Mar 18 22:34  18/583   "group" 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章