搭建postfix邮件服务器
2012-08-13 21:20
155 查看
需要安装的软件包:postfix
环境为:redhat 6.1 32bit
主配置文件 /etc/postfix/main.cf
运行参数配置/etc/postfix/master.cf
访问控制文件 /etc/postfix/access
别名数据库文件/etc/aliases
虚拟别名域库文件/etc/postfix/virtual
这次实验实现了收发邮件的基本功能,还有指定别名实现群发。
具体过程如下:
环境为:redhat 6.1 32bit
主配置文件 /etc/postfix/main.cf
运行参数配置/etc/postfix/master.cf
访问控制文件 /etc/postfix/access
别名数据库文件/etc/aliases
虚拟别名域库文件/etc/postfix/virtual
这次实验实现了收发邮件的基本功能,还有指定别名实现群发。
具体过程如下:
[root@localhost etc]# cd /var/named/chroot/var/named/ [root@localhost named]# ls 1.zone data named.ca named.localhost slaves chroot dynamic named.empty named.loopback [root@localhost named]# vim 1.zone #先修改DNS域名服务器,使之能够解析邮件服务器地址 $TTL 1D @ IN SOA example.com. root. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum NS chen @ MX 10 mail #@ 指在本域内,即example.com,MX为邮件服务器解析,10优先级,mail为邮件服务器的hostname mail A 192.169.1.100 #解析到自己 example.com. A 192.169.1.100 station1 A 192.169.1.100 www A 192.169.1.100 chen A 192.169.1.100 ftp CNAME www [root@localhost named]# service named restart 停止 named:..^C [root@localhost named]# ps aux|grep named root 6205 0.0 0.0 103244 860 pts/12 S+ 11:04 0:00 grep named named 30927 0.0 2.9 235964 30508 ? Ssl 01:36 0:05 /usr/sbin/named -u named -t /var/named/chroot [root@localhost named]# kill -9 30927 [root@localhost named]# service named start 启动 named: [确定] [root@localhost named]# nslookup www.example.com Server: 192.169.1.100 Address: 192.169.1.100#53 Name: www.example.com Address: 192.169.1.100 [root@localhost named]# nslookup mail.example.com #可以正常解析 Server: 192.169.1.100 Address: 192.169.1.100#53 Name: mail.example.com Address: 192.169.1.100 [root@localhost named]# hostname localhost.localdomain [root@localhost named]# hostname mail.example.com #修改hostname [root@localhost named]# vim /etc/sysconfig/network #写入配置文件 NETWORKING=yes HOSTNAME=mail.example.com [root@localhost named]# yum -y install postfix #安装postfix包 Loaded plugins: refresh-packagekit, rhnplugin This system is not registered with RHN. RHN support will be disabled. Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package postfix.i686 2:2.6.6-2.2.el6_1 set to be updated --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Updating: postfix i686 2:2.6.6-2.2.el6_1 rhel-source 2.0 M Transaction Summary ================================================================================ Install 0 Package(s) Upgrade 1 Package(s) Total download size: 2.0 M Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Updating : 2:postfix-2.6.6-2.2.el6_1.i686 1/2 Cleanup : 2:postfix-2.6.6-2.el6.i686 2/2 Updated: postfix.i686 2:2.6.6-2.2.el6_1 Complete! [root@localhost named]# cd /etc/postfix/ [root@localhost postfix]# ls access generic main.cf relocated virtual canonical header_checks master.cf transport [root@localhost postfix]# vim main.cf #修改主配置文件 #主要配置如下几个地方 myhostname = mail.example.com #本机主机名 mydomain = example.com #域名 myorigin = $mydomain #设置由本机寄出去的邮件所使用的域名或主机名 inet_interfaces = all #postfix所监听的网络 mydestination = $myhostname, localhost.$mydomain, localhost, example.com #设置可接受邮件的主机名和域名 mynetworks = 192.169.1.0/24 #设置在什么网络内收发邮件 relay_domains = $mydestination #设置在什么网域内收发邮件 [root@localhost postfix]# service postfix restart 关闭 postfix: [确定] 启动 postfix: [确定] [root@localhost postfix]# id user1 uid=502(user1) gid=502(user1) 组=502(user1) [root@localhost postfix]# mail user1 Subject: hello user1 nihao EOT [root@localhost postfix]# su - user1 [user1@mail ~]$ mail Heirloom Mail version 12.4 7/29/08. Type ? for help. "/var/spool/mail/user1": 1 message 1 new >N 1 root Mon Aug 13 11:14 18/551 "hello user1" & 1 Message 1: From root@example.com Mon Aug 13 11:14:57 2012 Return-Path: <root@example.com> X-Original-To: user1 Delivered-To: user1@example.com Date: Mon, 13 Aug 2012 11:14:57 +0800 To: user1@example.com Subject: hello user1 User-Agent: Heirloom mailx 12.4 7/29/08 Content-Type: text/plain; charset=us-ascii From: root@example.com (root) Status: R nihao & quit Held 1 message in /var/spool/mail/user1 [user1@mail ~]$ ------------------群发,指定别名------------------- [root@localhost postfix]# pwd /etc/postfix [root@localhost postfix]# ls access generic main.cf relocated virtual canonical header_checks master.cf transport [root@localhost postfix]# vim main.cf #指定别名数据库,第386和397行要打开,指定别名数据库 385 #alias_maps = dbm:/etc/aliases 386 alias_maps = hash:/etc/aliases 387 #alias_maps = hash:/etc/aliases, nis:mail.aliases 388 #alias_maps = netinfo:/aliases 389 390 # The alias_database parameter specifies the alias database(s) that 391 # are built with "newaliases" or "sendmail -bi". This is a separate 392 # configuration parameter, because alias_maps (see above) may specify 393 # tables that are not necessarily all under control by Postfix. 394 # 395 #alias_database = dbm:/etc/aliases 396 #alias_database = dbm:/etc/mail/aliases 397 alias_database = hash:/etc/aliases 398 #alias_database = hash:/etc/aliases, hash:/opt/majordomo/aliases [root@localhost postfix]# vim /etc/aliases You have new mail in /var/spool/mail/root 92 # trap decode to catch security attacks 93 decode: root 94 jinpeng.chen: user1, user2 #增加这行,jinpeng.chen为其他所有用户到别名 95 # Person who should get root's mail 96 #root: marc [root@localhost postfix]# newaliases #刷新别名数据库 [root@localhost postfix]# mail jinpeng.chen Subject: qunfa hello,everyone... . EOT [root@localhost postfix]# su - user1 [user1@mail ~]$ mail Heirloom Mail version 12.4 7/29/08. Type ? for help. "/var/spool/mail/user1": 2 messages 1 new 1 root Mon Aug 13 11:14 19/562 "hello user1" >N 2 root Mon Aug 13 11:35 18/578 "qunfa" & 2 Message 2: From root@example.com Mon Aug 13 11:35:36 2012 Return-Path: <root@example.com> X-Original-To: jinpeng.chen Delivered-To: jinpeng.chen@example.com Date: Mon, 13 Aug 2012 11:35:36 +0800 To: jinpeng.chen@example.com Subject: qunfa User-Agent: Heirloom mailx 12.4 7/29/08 Content-Type: text/plain; charset=us-ascii From: root@example.com (root) Status: R hello,everyone... & quit Held 2 messages in /var/spool/mail/user1 [user1@mail ~]$ exit logout [root@localhost postfix]# su - user2 [user2@mail ~]$ mail Heirloom Mail version 12.4 7/29/08. Type ? for help. "/var/spool/mail/user2": 1 message 1 new >N 1 root Mon Aug 13 11:35 18/578 "qunfa" & 1 Message 1: From root@example.com Mon Aug 13 11:35:37 2012 Return-Path: <root@example.com> X-Original-To: jinpeng.chen Delivered-To: jinpeng.chen@example.com Date: Mon, 13 Aug 2012 11:35:36 +0800 To: jinpeng.chen@example.com Subject: qunfa User-Agent: Heirloom mailx 12.4 7/29/08 Content-Type: text/plain; charset=us-ascii From: root@example.com (root) Status: R hello,everyone... & quit Held 1 message in /var/spool/mail/user2 [user2@mail ~]$
相关文章推荐
- Postfix邮件服务器搭建之虚拟用户配置
- postfix邮件服务器搭建
- 阿里云CentOS Linux服务器上用postfix搭建邮件服务器
- CentOS7.4中Postfix邮件服务器的搭建(一)-----环境配置及简单搭建
- 邮件服务器搭建 Centos+Postfix+Dovecot+Roundcube
- 搭建邮件服务器 Postfix + Dovecot (CentOS)
- Postfix邮件服务器搭建(一)
- postfix邮件服务器搭建
- ubuntu下用postfix搭建邮件服务器
- ubuntu下用postfix搭建邮件服务器
- CentOS Linux服务器上用postfix搭建php邮件服务器
- RedHat Enterprise Linux 5.4 搭建完整Postfix 邮件服务器
- CentOS 5.5 x64上使用Postfix + Dovecot + MySQL搭建邮件服务器
- Postfix邮件服务器搭建(二)
- linux redhat6.5中 搭建Postfix邮件服务器
- Centos7.1下用Postfix和Dovecot搭建邮件服务器
- [转]阿里云CentOS Linux服务器上用postfix搭建邮件服务器
- Linux运维高级篇—CentOS 7下Postfix邮件服务器搭建
- Postfix+Cyrus-SASL+dovecot搭建POP3/SMTP邮件服务器
- Postfix邮件服务器搭建(三)