zenmbu 发表于 2015-11-24 09:53:22

33-Linux-服务-postfix

  
  
说明
    Postfix是目前Linux下主流的邮件服务器(MTA),主要用来实现SMTP功能,
    之前的主流邮件服务是sendmail.


目的
    Postfix出现的目的就是为了改进sendmail


优势
    postfix的速度比sendmail快3倍
    兼容sendmail
    更加稳定健壮
    配置更加灵活
    大多数Postfix进程 运行在较低的权限下, 安全性更强


安装
    在CentOS6/RHEL6中, 默认已被安装且开机启动
    yum install -y postfix


启动
    service postfix start
    chkconfig postfix on
    默认占用 TCP的 25号端口 (SMTP)
    # chkconfig --list | grep postfix
    postfix         0:off   1:off   2:on    3:on    4:on    5:on    6:off


配置文件
    位置
      /etc/postfix/
    主配置文件
      /etc/postfix/main.cf
      
发邮件
    说明
      postfix默认启动, 但是只为本机提供服务
      监听本机的 127.0.0.1:25
      本机的用户之间可通过各种MUA相互发送邮件
    查看连接
      # netstat -tupln | grep master
    发送
      root用户给 wuqinfei用户发送邮件
      # mail -vs "helloWorldSubject" wuqinfei@localhost.wuhan
      hello postfix!
      EOT
      Mail Delivery Status Report will be mailed to <root>.
      You have mail in /var/spool/mail/root
    查看邮件
      邮件保存位置
            /var/spool/mail/用户名
      $ mail
      Heirloom Mail version 12.4 7/29/08.Type ? for help.
      &quot;/var/spool/mail/wuqinfei&quot;: 1 message 1 new
      >N1 root                  Tue Feb 25 22:4518/604   &quot;helloWorldSubject&quot;
      & 1
      Message1:
      From root@wuqinfei.wuhanTue Feb 25 22:45:55 2014
      Return-Path: <root@wuqinfei.wuhan>
      X-Original-To: wuqinfei@localhost.wuhan
      Delivered-To: wuqinfei@localhost.wuhan
      Date: Tue, 25 Feb 2014 22:45:54 &#43;0800
      To: wuqinfei@localhost.wuhan
      Subject: helloWorldSubject
      User-Agent: Heirloom mailx 12.4 7/29/08
      Content-Type: text/plain; charset=us-ascii
      From: root@wuqinfei.wuhan (root)
      Status: R


      hello postfix!


      & q
      Held 1 message in /var/spool/mail/wuqinfei
      You have mail in /var/spool/mail/wuqinfei
    配置
      postfix的主配置文件
            /etc/postfix/main.cf
      postconf命令
            使用postconf命令修改配置文件, 避免手动修改 造成的手误
            postconf -d 显示postfix的默认配置, default
            postconf -n 显示postfix的当前配置, now
            postconf -e key=value   修改指定属性的的值, edit
      基本配置选项
            mydomain = foo.org
            myhostname = mail.foo.org
            inet_interface = all
            mydestination = $myhostnam,localhost,$mydomain,localhost
            mynetworks = 127.0.0.0/8
            myorigin = $mydomain
      步骤
            1) 监听端口
                postfix默认值监听本地环回接口,即只为本机服务
                让其监听所有接口 即可 对外提供服务
                postconf -e &quot;inet_interface = all&quot;
            2) 设置表示本机的主机名
                myhostname = mail.foo.org
                mydomain = foo.org
                mydestination = $myhostnam,localhost,$mydomain,localhost
            3) 域伪装
                将 &quot;用户名@主机名&quot; 伪装成 &quot;用户名@域名&quot;
                postconf -e &quot;myorigin = $mydomain&quot;
      管理
            postqueue -p
                查看当前邮件发送队列
            postqueue -f
                刷新当前邮件发送队列
            tail -f /var/log/maillog
                查看日志
  
页: [1]
查看完整版本: 33-Linux-服务-postfix