邮件服务器搭建之: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" 

 

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