SMTPサーバ
解説
インターネット利用目的の2大要素としてウェブサイトの閲覧と
Eメール(電子メール)の利用が挙げられます。
インターネットは利用するがこれらを利用しないという人はまずいないと思います。
これはイントラネットにおいてもほぼ同様でEメールを使って
連絡事項を送付したり、コミュニケーションを図るという機会は少なくないと思われます。
Eメールは送信するための機能と、受信するための機能が別々に分かれているため、
メール送信、受信の両方を行うためには
それぞれについて環境を構築しなければなりません。
SMTPサーバはこれらのうちメールの送信機能を持ち、相手先のメールサーバまで
メールを届けるためのサービスを提供します。
対応バージョン
postfix-2.2.8-1.2(Fedora Core 5標準)
インストール
インストール前に初期状態で起動しているSMTPサーバのsendmailを停止します。
また、自動起動の設定も解除します。
SMTPサーバに必要なパッケージを1つインストールします。 DVDドライブにFedora Core 5のDVD-ROMをセットし、以下のコマンドを実行します。
SMTPサーバに必要なパッケージを1つインストールします。 DVDドライブにFedora Core 5のDVD-ROMをセットし、以下のコマンドを実行します。
# /etc/rc.d/init.d/sendmail stop
sendmail を停止中: [ OK ]
sm-client を停止中: [ OK ]
# chkconfig sendmail off
# mount /media/cdrom
# cd /media/cdrom/Fedora/RPMS
# rpm -ihv postfix-2.2.8-1.2.i386.rpm
準備中... ########################################### [100%]
1:postfix ########################################### [100%]
# cd /
# umount /media/cdrom
sendmail を停止中: [ OK ]
sm-client を停止中: [ OK ]
# chkconfig sendmail off
# mount /media/cdrom
# cd /media/cdrom/Fedora/RPMS
# rpm -ihv postfix-2.2.8-1.2.i386.rpm
準備中... ########################################### [100%]
1:postfix ########################################### [100%]
# cd /
# umount /media/cdrom
設定
ここではイントラネットでメールを送信するための設定を行います。
基本的にはイントラネット内でのメール交換だけを目的としていますが、
イントラネット外部のインターネットへもメールを送信することができます。
ただし、外部からのメールは受け付けません。
(1) MTAの選択
Postfixをインストールした後はSMTPサーバとして
SendmailとPostfixの2つが利用できる状態となっています。
まず始めにこれらのうちどちらを利用するか選択します。
# alternatives --config mta
2 プログラムがあり 'mta' を提供します。
選択 コマンド
-----------------------------------------------
*+ 1 /usr/sbin/sendmail.sendmail
2 /usr/sbin/sendmail.postfix
Enter を押して現在の選択 [+] を保持するか、選択番号を入力します:2 ←2を入力
2 プログラムがあり 'mta' を提供します。
選択 コマンド
-----------------------------------------------
*+ 1 /usr/sbin/sendmail.sendmail
2 /usr/sbin/sendmail.postfix
Enter を押して現在の選択 [+] を保持するか、選択番号を入力します:2 ←2を入力
(2) SMTPサーバの設定
viエディタで設定ファイル(main.cf)を開き、設定を変更します。
# cd /etc/postfix/
# vi main.cf
ファイル(/etc/postfix/main.cf)# vi main.cf
※以下、該当箇所のみ変更※
#myhostname = host.domain.tld
#myhostname = virtual.domain.tlc
↓変更
myhostname = svr1.ranonet.ne.jp ←#を外して設定を変更
#myhostname = virtual.domain.tlc
#mydomain = domain.tld
↓変更
mydomain = ranonet.ne.jp ←#を外して設定を変更
#myorigin = $myhostname
#myorigin = $mydomain
↓変更
#myorigin = $myhostname
myorigin = $mydomain ←#を外す
#inet_interfaces = all
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
inet_interfaces = localhost
↓変更
inet_interfaces = all ←#を外す
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
#inet_interfaces = localhost ←#を付ける
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 ←#を付ける
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain ←#を外す
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
# mail.$mydomain, www.$mydomain, ftp.$mydomain
#mynetworks = 168.100.189.0/24, 127.0.0.0/8
#mynetworks = $config_directory/mynetworks
#mynetworks = hash:/etc/postfix/network_table
↓変更
mynetworks = 192.168.0.0/24, 127.0.0.0/8 ←#を外して設定を変更
#mynetworks = $config_directory/mynetworks
#mynetworks = hash:/etc/postfix/network_table
#myhostname = host.domain.tld
#myhostname = virtual.domain.tlc
↓変更
myhostname = svr1.ranonet.ne.jp ←#を外して設定を変更
#myhostname = virtual.domain.tlc
#mydomain = domain.tld
↓変更
mydomain = ranonet.ne.jp ←#を外して設定を変更
#myorigin = $myhostname
#myorigin = $mydomain
↓変更
#myorigin = $myhostname
myorigin = $mydomain ←#を外す
#inet_interfaces = all
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
inet_interfaces = localhost
↓変更
inet_interfaces = all ←#を外す
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
#inet_interfaces = localhost ←#を付ける
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 ←#を付ける
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain ←#を外す
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
# mail.$mydomain, www.$mydomain, ftp.$mydomain
#mynetworks = 168.100.189.0/24, 127.0.0.0/8
#mynetworks = $config_directory/mynetworks
#mynetworks = hash:/etc/postfix/network_table
↓変更
mynetworks = 192.168.0.0/24, 127.0.0.0/8 ←#を外して設定を変更
#mynetworks = $config_directory/mynetworks
#mynetworks = hash:/etc/postfix/network_table
(3) SMTPサーバの起動ランレベル変更
Postfixはインストールした状態でOSの起動に併せてデーモンを
自動起動する設定になっているため設定の変更は不要です。
以上で設定が終了しましたのでrcスクリプトを使用してデーモンを起動します。
以上で設定が終了しましたのでrcスクリプトを使用してデーモンを起動します。
# /etc/rc.d/init.d/postfix start
