目次




目的

メールサーバとして使用する訳ではなく、cronでのスクリプト実行で異常発生した場合等にメールで通知する為だけに利用する。

準備

インストール

  1. yum でインストール
    # yum install postfix

設定

  1. main.cf の編集
    # vi /etc/postfix/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 = hogehoge.mydomain.com                                       ← 追加
    
    # 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 = mydomain.com                                                  ← 追加
    
    # 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
    inet_interfaces = localhost                                              ← 確認(ローカルからの送信しかしない)
    
    # Enable IPv4, and IPv6 if supported
    inet_protocols = all
    
    (〜略〜) 
    
    # 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/
    home_mailbox = Maildir/                                                  ← 追加
    
    (〜略〜) 
    
    # SHOW SOFTWARE VERSION OR NOT
    #
    # The smtpd_banner parameter specifies the text that follows the 220
    # code in the SMTP server's greeting banner. Some people like to see
    # the mail version advertised. By default, Postfix shows no version.
    #
    # You MUST specify $myhostname at the start of the text. That is an
    # RFC requirement. Postfix itself does not care.
    #
    #smtpd_banner = $myhostname ESMTP $mail_name
    #smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
    smtpd_banner = $myhostname ESMTP unknown                                 ← 追加(メールサーバーソフト名の隠蔽)
    
    (〜略〜) 
    

  2. master.cf の編集
    # vi /etc/postfix/master.cf

    smtp      inet  n       -       n       -       -       smtpd
    ↓コメントアウト
    #smtp      inet  n       -       n       -       -       smtpd

  3. メールボックスのディレクトリを作成
    # mkdir -p /etc/skel/Maildir/{new,cur,tmp}
    # chmod -R 700 /etc/skel/Maildir/

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

  5. 動作確認
    1. 起動
      # /etc/rc.d/init.d/postfix start
      postfix を起動中:                                          [  OK  ]

    2. メールを送ってみる
      # mail -s "[$HOSTNAME] TEST" hoge@mydomain.com
      Sample message
      .               ← .(ドット)で本文終了
      hoge@mydomain.com にメールが届けば完了。

  6. 自動起動設定
    # # chkconfig postfix on

メモ


トップ   編集 凍結解除 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2023-05-10 (水) 20:53:53