邮件服务器搭建之: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”命令进行,后面添加相应的start、stop、check、reload参数即可分别启动、停止、检查、重载postfix服务。
- [[email protected] ~]# 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 //指定邮件别名的文件路径
- [[email protected] ~]# /etc/init.d/postfix restart
- Shutting down postfix: [ OK ]
- Starting postfix: [ OK ]
- [[email protected] ~]# mail -s 'postfix_test1' [email protected] < /etc/hosts
- [[email protected] ~]# echo "postfix test again" | mail -s 'postfix_test2' [email protected]
- 查看[email protected]用户收到的邮件
- [[email protected] ~]# 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
查看[email protected]用户收到的邮件
-
/etc/aliases应用:
- 1.邮件别名设置:用户user1可以接收其他用户发给user2的邮件,user2用户将收不到邮件(user2 --> user1)
- [[email protected] ~]# vi /etc/aliases
- user2: user1
- [[email protected] ~]# postalias /etc/aliases
- 2.邮件群组设置:将user1、user2、user3...组成一个组group,则发给group的邮件将转发给user1、user2、user3...
- [[email protected] ~]# vi /etc/aliases
- groupname: user1,user2,user3
- [[email protected] ~]# postalias /etc/aliases
- [[email protected] ~]# echo "mail group test" | mail -s 'group' [email protected]
- [[email protected] ~]# 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"
- [[email protected] ~]# 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"
- [[email protected] ~]# 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"
转载于:https://blog.51cto.com/vnimos/1176083