Postfix のインストール

2005.08.29

送信メールサーバーとして、Postfixを使用する。

  1. インストール
  2. RPMパッケージのインストールやアンインストール、アップデートなどを行うためのプログラム、 yum コマンドを使用して、Postfix メールサーバ(MTA)のインストールを行う。

    1. postfix パッケージをインストール
    2. [root@siva /]# yum install postfix
      Setting up Install Process
      Setting up Repo:  base
      repomd.xml                100% |=========================| 1.1 kB    00:00
      Setting up Repo:  updates-released
      http://fedora-mirror.dkuug.dk/linux/core/updates/3/i386/repodata/repomd.xml: [Errno 4] IOError: HTTP Error 404: Not Foun
      d
      Trying other mirror.
      repomd.xml                100% |=========================|  951 B    00:00
      Reading repository metadata in from local files
      primary.xml.gz            100% |=========================| 797 kB    00:06
      MD Read   : ################################################## 2623/2623
      base      : ################################################## 2622/2622
      primary.xml.gz            100% |=========================| 133 kB    00:02
      MD Read   : ################################################## 330/330
      updates-re: ################################################## 330/330
      Resolving Dependencies
      --> Populating transaction set with selected packages. Please wait.
      ---> Downloading header for postfix to pack into transaction set.
      postfix-2.1.5-2.4.FC3.i38 100% |=========================|  39 kB    00:00
      ---> Package postfix.i386 2:2.1.5-2.4.FC3 set to be installed
      --> Running transaction check
      
      Dependencies Resolved
      Transaction Listing:
        Install: postfix.i386 2:2.1.5-2.4.FC3
      Is this ok [y/N]: y
      Downloading Packages:
      postfix-2.1.5-2.4.FC3.i38 100% |=========================| 2.7 MB    00:32
      Running Transaction Test
      Finished Transaction Test
      Transaction Test Succeeded
      Running Transaction
      Installing: postfix 100 % done 1/1
      
      Installed: postfix.i386 2:2.1.5-2.4.FC3
      Complete!
      

    3. ダウンロードしたパッケージと古いヘッダを削除
    4. [root@siva tmp]# yum clean packages
      

  3. 使用するメールサーバ(MTA)切り替え
  4. [root@siva /]# /usr/sbin/alternatives --config mta
    
    2 プログラムがあり 'mta'を提供します。
    
      選択       コマンド
    -----------------------------------------------
    *+ 1           /usr/sbin/sendmail.sendmail
       2           /usr/sbin/sendmail.postfix
    
    Enterを押して現在の選択[+]を保持するか、選択番号を入力します:2
    

  5. 起動と停止
  6. [root@siva work]# /sbin/service sendmail stop
    sendmail を停止中:                                         [  OK  ]
    sm-client を停止中:                                        [  OK  ]
    [root@siva work]# /sbin/service postfix start
    Starting postfix:                                          [  OK  ]
    

  7. 設定ファイルの更新
  8. [root@oolong postfix]# pwd
    /etc/postfix
    [root@oolong postfix]# vi main.cf
    
    # INTERNET HOST AND DOMAIN NAMES
    #
    # The myhostname parameter specifies the internet hostname of this
    # mail system. The default is to use the fully-qualified domain name
    # from gethostname(). $myhostname is used as a default value for many
    # other configuration parameters.
    #
    #myhostname = host.domain.tld
    #myhostname = virtual.domain.tld
    myhostname = typea.bne.jp
    
    # The mydomain parameter specifies the local internet domain name.
    # The default is to use $myhostname minus the first component.
    # $mydomain is used as a default value for many other configuration
    # parameters.
    #
    #mydomain = domain.tld
    mydomain = typea.bne.jp
    
    # SENDING MAIL
    #
    # The myorigin parameter specifies the domain that locally-posted
    # mail appears to come from. The default is to append $myhostname,
    # which is fine for small sites.  If you run a domain with multiple
    # machines, you should (1) change this to $mydomain and (2) set up
    # a domain-wide alias database that aliases each user to
    # user@that.users.mailhost.
    #
    # For the sake of consistency between sender and recipient addresses,
    # myorigin also specifies the default domain name that is appended
    # to recipient addresses that have no @domain part.
    #
    #myorigin = $myhostname
    #myorigin = $mydomain
    myorigin = $mydomain
    
    # RECEIVING MAIL
    
    # The inet_interfaces parameter specifies the network interface
    # addresses that this mail system receives mail on.  By default,
    # the software claims all active interfaces on the machine. The
    # parameter also controls delivery of mail to user@[ip.address].
    #
    # See also the proxy_interfaces parameter, for network addresses that
    # are forwarded to us via a proxy or network address translator.
    #
    # Note: you need to stop/start Postfix when this parameter changes.
    #
    #inet_interfaces = all
    #inet_interfaces = $myhostname
    #inet_interfaces = $myhostname, localhost
    # rem 20041205 inet_interfaces = localhost
    inet_interfaces = all
    
    # The unknown_local_recipient_reject_code specifies the SMTP server
    # response code when a recipient domain matches $mydestination or
    # ${proxy,inet}_interfaces, while $local_recipient_maps is non-empty
    # and the recipient address or address local-part is not found.
    # The local machine is always the final destination for mail addressed
    # to user@[the.net.work.address] of an interface that the mail system
    # receives mail on (see the inet_interfaces parameter).
    #
    # Specify a list of host or domain names, /file/name or type:table
    # patterns, separated by commas and/or whitespace. A /file/name
    # pattern is replaced by its contents; a type:table is matched when
    # a name matches a lookup key (the right-hand side is ignored).
    # Continue long lines by starting the next line with whitespace.
    #
    # See also below, section "REJECTING MAIL FOR UNKNOWN LOCAL USERS".
    #
    # rem 20041205 mydestination = $myhostname, localhost.$mydomain, localhost
    #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
    #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
    #       mail.$mydomain, www.$mydomain, ftp.$mydomain
    mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
    
    # TRUST AND RELAY CONTROL
    
    # The MYNetworks parameter specifies the list of "trusted" SMTP
    # clients that have more privileges than "strangers".
    #
    # In particular, "trusted" SMTP clients are allowed to relay mail
    # through Postfix.  See the smtpd_recipient_restrictions parameter
    # in postconf(5).
    #
    # You can specify the list of "trusted" network addresses by hand
    # or you can let Postfix do it for you (which is the default).
    #
    # By default (mynetworks_style = subnet), Postfix "trusts" SMTP
    # clients in the same IP subnetworks as the local machine.
    # On Linux, this does works correctly only with interfaces specified
    # with the "ifconfig" command.
    #
    # Specify "mynetworks_style = class" when Postfix should "trust" SMTP
    # clients in the same IP class A/B/C networks as the local machine.
    # Don't do this with a dialup site - it would cause Postfix to "trust"
    # your entire provider's network.  Instead, specify an explicit
    # mynetworks list by hand, as described below.
    #
    # Specify "mynetworks_style = host" when Postfix should "trust"
    # only the local machine.
    #
    #mynetworks_style = class
    #mynetworks_style = subnet
    #mynetworks_style = host
    mynetwork_style = subnet
    
    # DELIVERY TO MAILBOX
    #
    # The home_mailbox parameter specifies the optional pathname of a
    # mailbox file relative to a user's home directory. The default
    # mailbox file is /var/spool/mail/user or /var/mail/user.  Specify
    # "Maildir/" for qmail-style delivery (the / is required).
    #
    #home_mailbox = Mailbox
    #home_mailbox = Maildir/
    
    # dovecotのdefault_mail_envとあわせる
    home_mailbox = Mailbox
    

  9. 再起動
  10. [root@siva postfix]# /sbin/service postfix restart
    Shutting down postfix:                                     [  OK  ]
    Starting postfix:                                          [  OK  ]
    

  11. 設定のリロード
  12. [root@siva postfix]# /sbin/service postfix reload
    Reloading postfix:                                         [  OK  ]
    

  13. 新規追加するユーザのホームディレクトリにMailboxファイル(/home/ユーザ名/Mailbox)が自動で作成されるようにする
  14. [root@siva /]# touch /etc/skel/Mailbox
    [root@siva /]# chmod 660 /etc/skel/Mailbox
    

  15. sendmailをアンインストール
  16. [root@siva Mailbox]# yum -y remove sendmail
    Setting up Remove Process
    Resolving Dependencies
    --> Populating transaction set with selected packages. Please wait.
    ---> Package sendmail.i386 0:8.13.1-2 set to be erased
    --> Running transaction check
    
    Dependencies Resolved
    Transaction Listing:
      Remove: sendmail.i386 0:8.13.1-2
    Downloading Packages:
    Running Transaction Test
    Finished Transaction Test
    Transaction Test Succeeded
    Running Transaction
    warning: /var/log/mail/statistics saved as /var/log/mail/statistics.rpmsave
    warning: /etc/mail/submit.cf saved as /etc/mail/submit.cf.rpmsave
    Erasing: sendmail 1/1
    
    Removed: sendmail.i386 0:8.13.1-2
    Complete!