powerdee.com
Google
 
このサイト内 Web
 
カウンタ

メールサーバ構築

sendmailの確認

sendmailは、Linuxインストール時に自動的にインストールされていますが、なるべくならセキュリティのために最新版にアップデートしておきます。
インストールされているパッケージを確認します。

$ rpm -qa | grep sendmail
sendmail-devel-8.12.11-4.RHEL3.1
sendmail-cf-8.12.11-4.RHEL3.1
sendmail-8.12.11-4.RHEL3.1

sendmailの設定ファイル

/etc/mail/access

標準ではローカルドメインとローカルホストにのみメールリレーを許可しています。プライベートネットワークからのリレーを許可します。
また、メールを拒否して受信しないようにするには、「REJECT」を指定します。

# 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
192.168.0                       RELAY   <-- プライベートネットワークからのリレーを許可
spam@hoge.co.jp                 REJECT  <-- 特定のメールアドレスを拒否

/etc/mail/sendmail.mc

sendmail.mcはsendmail本体の設定ファイルである、sendmail.cfを生成するための設定ファイルです。

標準はローカルホストからしか受け付けないように設定されているため、下記をコメント(dnlを挿入)にします。

DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl

dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl

このサーバー上のユーザーから送られた場合の受信メールのFrom : のホスト名を指定します。

Cwpowerdee.com

マスカレードはアドレスのホスト名の部分を書き換えます。
例えば、ホスト名が host.powerdee.com だとすると、ユーザのメールアドレスは user@host.powerdee.com となりますが、下記を指定すると user@powerdee.com になります。

dnl MASQUERADE_AS(`mydomain.com')dnl

MASQUERADE_AS(`powerdee.com')dnl

dnl FEATURE(masquerade_envelope)dnl

FEATURE(masquerade_envelope)dnl

sendmail.cfの作成

# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

設定ファイルのDBM化

/etc/mail/sendmail.mcファイルを除いて、makeコマンドで変更した設定ファイルをDBMに変換しておく必要があります。

# cd /etc/mail
# make
# /etc/init.d/sendmail restart
sendmailを停止中:                                          [  OK  ]
sm-clientを停止中:                                         [  OK  ]
sendmailを起動中:                                          [  OK  ]
sm-clientを起動中:                                         [  OK  ]

POPサーバの起動

popサーバはipop3を起動するように設定します。/etc/xinetd.d/ipop3を編集します。

# default: off
# description: The POP3 service allows remote users to access their mail \
#              using an POP3 client such as Netscape Communicator, mutt, \
#              or fetchmail.
service pop3
{
        socket_type             = stream
        wait                    = no
        user                    = root
        server                  = /usr/sbin/ipop3d
        log_on_success  += HOST DURATION
        log_on_failure  += HOST
        disable                 = no   <-- yes を noに変更
}

xinetdを再起動します。

# /etc/init.d/xinetd restart
xinetdを停止中:                                            [  OK  ]
xinetdを起動中:                                            [  OK  ]

配信テスト

telnetでsmtpサーバ(25番ポート)に接続して配信テストをします。結果をメールクライアントから受信できればOKです。

# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 host.powerdee.com ESMTP Sendmail 8.12.11/8.12.11; Sun, 20 Feb 2005 17:45:02 +0900
helo powerdee.com
250 host.powerdee.com Hello localhost.localdomain [127.0.0.1], pleased to meet you
mail from:<root@powerdee.com>
250 2.1.0 <root@powerdee.com>... Sender ok
rcpt to:<webmaster@powerdee.com>
250 2.1.5 <webmaster@powerdee.com>... Recipient ok
data
354 Enter mail, end with "." on a line by itself
Subject: test mail

this is a test
.
250 2.0.0 j1K8j2wr003471 Message accepted for delivery
quit
221 2.0.0 host.powerdee.com closing connection
Connection closed by foreign host.

おすすめ書籍


Linux教科書 LPICレベル1 第2版 (Linux教科書)

著者:中島 能和、濱野 賢一朗
出版社:翔泳社(2006-08-11)
価格:¥3,990(税込)
Linuxカーネル2.6解読室

著者:高橋浩和、小田逸郎、山幡為佐久
出版社:ソフトバンククリエイティブ(2006-11-18)
価格:¥5,670(税込)


ページTopへ / ▲Homeへ