#contents
 ----
 * sendmail? [#peba31f4]
 
  Fedora Core 4 では標準の MTA として sendmail(センドメール)がセットアップされています。
 
  とりあえず最低限使うための設定をここに記述します。詳しい設定は他の方のページにおまかせするとして、とにかく使いたい!!ってな時にご利用ください〜。
 
 
 * 設定ファイルの場所 [#x8263d26]
 
  sendmail の諸設定ファイルは /etc/mail 以下のディレクトリにあります。
 
  $ ls -al /etc/mail
  合計 276
  drwxr-xr-x   3 root root  4096  6月 14 19:13 .
  drwxr-xr-x  93 root root 12288  6月 24 20:05 ..
  -rw-r--r--   1 root root  1035  5月  6 21:35 Makefile
  -rw-r--r--   1 root root   331  5月  6 21:35 access
  -rw-r-----   1 root root 12288  6月 14 19:09 access.db
  -rw-r--r--   1 root root     0  5月  6 21:35 domaintable
  -rw-r-----   1 root root 12288  6月 14 19:09 domaintable.db
  -rw-r--r--   1 root root  5588  5月  6 21:35 helpfile
  -rw-r--r--   1 root root    64  5月  6 21:35 local-host-names
  -rw-r--r--   1 root root     0  5月  6 21:35 mailertable
  -rw-r-----   1 root root 12288  6月 14 19:09 mailertable.db
  -rw-r--r--   1 root root 58079  6月 14 19:09 sendmail.cf
  -rw-r--r--   1 root root  7069  5月  6 21:35 sendmail.mc
  drwxr-xr-x   2 root root  4096  6月 14 19:13 spamassassin
  -r--r--r--   1 root root 41348  5月  6 21:35 submit.cf
  -rw-r--r--   1 root root   952  5月  6 21:35 submit.mc
  -rw-r--r--   1 root root   127  5月  6 21:35 trusted-users
  -rw-r--r--   1 root root     0  5月  6 21:35 virtusertable
  -rw-r-----   1 root root 12288  6月 14 19:09 virtusertable.db
 
  このなかで頻繁にお世話になるのが【 access 】と【 sendmail.mc 】です。
 
 ** local-host-names の編集 [#z21f73b6]
 
  /etc/mail/local-host-names
 
  このファイルの中にサーバが扱う(このサーバにメールが送られてくる)ドメイン名またはサブドメイン名を記述します。
 
  たとえば、該当サーバで【 ユーザ@example.jp 】と【 ユーザ@hoehoe.jp 】を使いたい場合、ファイル中には次のようにドメイン名を列挙しておきます。
 
  # local-host-names - include all aliases for your machine here.
  example.jp
  hoehoe.jp
  この記述は「サーバが扱うメールのドメイン名」の定義です。ここに記述されていないメールは扱われない=迷惑メール対策にもなります。
 
 ** sendmail.mc の設定 [#uf6f3967]
 
  sendmail.mc は sendmail の設定ファイル sendmail.cf の元となっているファイルです。この sendmail.mc ファイルは M4 マクロ形式で記述されています。
 
  vi /etc/mail/sendmail.mc
  などで、ファイルを編集します。
 
  編集点は下記の通りです。まず 112 行目を変更します。
  DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
  初期状態では 127.0.0.1(自分自身)に対してのみ SMTP ポートを開きます。これではメールを外部に送ることはできても、メールを受け取ることは出来ません。
  DAEMON_OPTIONS(`Port=smtp,Addr=210.239.46.254, Name=MTA')dnl
  Addr の後ろに該当サーバの IP アドレスを記述するか、以下のように行自体をコメントにして無効にしてもいいです(M4 マクロでは dnl がコメントの意味です)
  dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
 
  次は 151 行目の編集です。
 
  LOCAL_DOMAIN(`localhost.localdomain')dnl
  初期状態ではこのように、自ホスト名が localhost.localdomain となっています。
 
  このままではメールの配送に支障が出ますので、自分のホスト名を適切に記述します。たとえば、hoehoe.jp であれば
  LOCAL_DOMAIN(`hoehoe.jp')dnl
  このように書き換えます。
 
  最後に、自ホスト名を Cw で定義します。sendmail.mc の末尾に、ドメインが hoehoe.jp であるなら
  Cwhoehoe.jp
  このようにして記述しておきます。この記述は無くてもよいのですが、sendmail は自分のホスト名を "localhost.localdomain" として認識されてしまうので、念のために自ホスト名は記述することに越したことはありません。
 
  以上で sendmail.m4 の最低限の設定は終わりです。
 
 ** sendmail.mc から sendmail.cf の作成 [#a03f7f69]
 
  次のコマンドを実行して sendmail.cf の構築を行います。
 
  # m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
  実行しても特に結果は出ません。sendmail.cf ファイルがこれで準備できました。
 
 ** /etc/mail/access による利用者の制限 [#r3e97d82]
 
  このファイルで「制限」を行わないと、世界中の誰でもそのサーバからメールが発信できてしまいます。つまり予期せぬ利用をされることもあります(スパムメール発信の為の踏み台)。そうならないよう、access ファイルで適切に制限をかける必要があります。
 
  vi エディタでファイルを開き【許可する環境   RELAY】のように記述します。
 
  # Check the /usr/share/doc/sendmail/README.cf file for a description
  # of the format of this file. (search for access_db in that file)
  # The /usr/share/doc/sendmail/README.cf is part of the sendmail-doc
  # package.
  #
  # by default we allow relaying from localhost...
  localhost.localdomain           RELAY
  localhost                       RELAY
  127.0.0.1                       RELAY
  example.jp                      RELAY
  192.168.                        RELAY
 
  記述が終わったら access.db ファイルを構築します(sendmail は直接 /etc/mail/access ファイルを読むことは出来ません)。
 
  # makemap hash /etc/mail/access.db < /etc/mail/access
 
  この access ファイルに記述されていない環境から送信を試みようとすると、/var/log/maillog に次のようなログが記録されます。
 
  Jun 24 20:54:02 sion sendmail[4937]: j5OBs2fs004937: ruleset=check_rcpt, 
  arg1=<to@example.jp>, relay=dhcp102.internal [192.168.11.102], 
  reject=550 5.7.1 <from@example.jp>... Relaying denied
 
  【 reject=550 5.7.1 】の【 Relaying denied 】=メールの中継を拒否した、という記録です。正しく環境が /etc/mail/access に記入されているかどうか、再確認をされることをおすすめします。
 
 ** sendmail の起動テスト [#bdc00684]
 
  # /sbin/service sendmail start
  sendmail を起動中:                                         [  OK  ]
  sm-client を起動中:                                        [  OK  ]
 
  特に問題なければ、そのまま OK と表示されます。
 
 
 ** sendmail の自動起動設定 [#h2cbb310]
 
  初期状態で sendmail パッケージが選択されていれば、自動起動する設定になっています。
 
  # /sbin/chkconfig --list sendmail
  sendmail        0:off   1:off   2:on    3:on    4:on    5:on    6:off
 
  もし自動起動しないような設定であれば、chkconfig で変更をかけます。
  # /sbin/chkconfig sendmail on
 ----
  引き続きメール受信サーバ(MRA) dovecot の設定を行う場合は次のページをご参照下さい。
 
 [[dovecot による MRA(メール受信サーバ)を用いた pop3,pop3s,imap,imap4構築:http://pocketstudio.jp/linux/?FC4%2Fdovecot%2Fdovecot%20%A4%CB%A4%E8%A4%EB%20MRA%28%A5%E1%A1%BC%A5%EB%BC%F5%BF%AE%A5%B5%A1%BC%A5%D0%29%A4%F2%CD%D1%A4%A4%A4%BF%20pop3%2Cpop3s%2Cimap%2Cimap4%B9%BD%C3%DB]]

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS