「2004/07/20」
0.メールサーバとは
一般的にメールサーバとは、メールを配送を行うSMTPサーバと、メールを読み出しのためのPOP3サーバ若しくはIMAP4サーバの組み合わせのことを言います。
1.SMTP(Sendmail)の構築
sendmailの設定を変更するには、/etc/mail/sendmail.cfという設定ファイルを変更する必要があります。しかし、このファイルを直接編集するのは大変なのです、”.mc”という拡張子のファイルを編集し、このファイルからsendmail.cfを作成します。
1−0ディレクトリ構造
/etc/rc.d/init.d/sendmail | sendmailを制御するスプリクト |
/etc/mail/sendmail.cf | メインの設定ファイル |
/etc/mail/access | メールリレーを許可するファイル |
/usr/sbin/sendmail | SMTPデーモン |
/var/spool/mail | メールの保存用ディレクトリ |
/var/apool/mqueue | メールキュー用ディレクトリ |
/var/log/maillog | ログが記録されているファイル |
1−1インストール
# rpm -ihv m4-1.4.1-15.i386.rpm
警告: m4-1.4.1-15.i386.rpm: V3 DSA signature: NOKEY, key ID *****
Preparing... ########################################### [100%]
1:m4 ########################################### [100%]
# rpm -ihv sendmail-cf-8.12.11-4.6.i386.rpm
警告: sendmail-cf-8.12.11-4.6.i386.rpm: V3 DSA signature: NOKEY, key ID
*****
Preparing... ########################################### [100%]
1:sendmail-cf ########################################### [100%]
1−2初期設定
(設定ファイル)
# vi /etc/mail/sendmail.mc
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
(以下のとおりコマンド実行)
# m4 /usr/share/sendmail-cf/m4/cf.m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
(Sendmailを再起動)
# /etc/rc.d/init.d/sendmail reload
sendmailを停止中: [ OK ]
sm-clientを停止中: [ OK ]
sendmailを起動中: [ OK ]
sm-clientを起動中: [ OK ]
1−3サーバ外からの接続許可
(設定ファイル)
# vi /etc/hosts.allow
(追加記入)
sendmail : ALL
2.POP3/IMAPの構築
2−1インストール
# rpm -ihv dovecot-0.99.10.4-4.i386.rpm
警告: dovecot-0.99.10.4-4.i386.rpm: V3 DSA signature: NOKEY, key ID *****
Preparing... ########################################### [100%]
1:dovecot ########################################### [100%]
(ファイルの設定)
# vi /etc/dovecot.conf
# Protocols we want to be serving: # imap imaps pop3 pop3s #protocols = imap imaps protocols = imap imaps pop3 pop3s 「追加」 |
(サービス開始コマンド)
# /etc/rc.d/init.d/dovecot start
Dovecot Imapを起動中: [ OK ]
(自動起動の設定)
# chkconfig dovecot on
2−2メールアドレスの作成
# useradd -s /sbin/nologin testuser
# passwd testuser
3.Sendmailの詳しい設定
3−1他のサーバにメールを送信できるようにする。
(設定ファイル)
# vi /etc/mail/access
# 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「追加」*リレーすべき最小限のもののみ記載すること。
ファイルの保存後
# makemap hash /etc/mail/access.db < /etc/mail/access
これでメールのリレーが可能です。sendmailのリロードは必要ありません
3−2複数のドメイン名でメールを受信できるようにする。
(設定ファイル)
# vi /etc/mail/local-host-names
# local-host-names - include all aliases for your machine here.
kkataru.mine.nu「ドメイン」
ataru01.kkataru.mine.nu「PC名」
192.168.0.1「IP」
(再起動)
# /etc/rc.d/init.d/sendmail reload
sendmailを停止中: [ OK ]
sm-clientを停止中: [ OK ]
sendmailを起動中: [ OK ]
sm-clientを起動中: [ OK ]
3−3複数アドレスに一括で送信する同報用アドレス
# vi /etc/aliases
# Person who should get root's mail
#root: marc
root: post(追加)
# newaliases(再起動)
/etc/aliases: 64 aliases, longest 10 bytes, 633
bytes total
*これを利用してメーリングも作成できます。