■概要

メールサーバーを構築する場合、送信メールサーバー(SMTPサーバー)と受信メールサーバー(POP/IMAPサーバー)の構築が必要となる。
ここでは、送信メールサーバーには安全確実高性能といわれるqmail(日本語訳)、受信メールサーバーのうち、POPサーバーにはqmail、IMAPサーバーにはDovecotを採用する。
また、受信メールサーバーはPOPサーバー、IMAPサーバーの両方を構築して利用者が選択できるようにする(POPとIMAPの違い)。
※どちらか一方だけの構築でも構わない

なお、迷惑メールの不正中継対策(迷惑メールの不正中継に利用されずに外部からメールを送信できるようにする対策)としてSMTP認証(SMTP-Auth)を導入する。


■qmailインストール

(1)qmailインストール準備
qmailインストールに必要なユーザ、グループを作成する
[root@centos ~]# mkdir /var/qmail ← qmailインストールディレクトリ作成

[root@centos ~]# groupadd nofiles ← nofilesグループ作成

[root@centos ~]# useradd -g nofiles -s /sbin/nologin alias -m -d /var/qmail/alias -k /dev/null ← aliasユーザ作成

[root@centos ~]# useradd -g nofiles -d /var/qmail -s /sbin/nologin -M qmaild ← qmaildユーザ作成

[root@centos ~]# useradd -g nofiles -d /var/qmail -s /sbin/nologin -M qmaill ← qmaillユーザ作成

[root@centos ~]# useradd -g nofiles -d /var/qmail -s /sbin/nologin -M qmailp ← qmailpユーザ作成

[root@centos ~]# groupadd qmail ← qmailグループ作成

[root@centos ~]# useradd -g qmail -d /var/qmail -s /sbin/nologin -M qmailq ← qmailqユーザ作成

[root@centos ~]# useradd -g qmail -d /var/qmail -s /sbin/nologin -M qmailr ← qmailrユーザ作成

[root@centos ~]# useradd -g qmail -d /var/qmail -s /sbin/nologin -M qmails ← qmailsユーザ作成

(2)qmailインストール
[root@centos ~]# wget ftp://ftp.jp.qmail.org/qmail/qmail-1.03.tar.gz ← qmailダウンロード

※wgetが固まってダウンロードできない場合は下記手順でダウンロード
[root@centos ~]# wget --no-passive-ftp ftp://ftp.jp.qmail.org/qmail/qmail-1.03.tar.gz ← qmailダウンロード

[root@centos ~]# tar zxvf qmail-1.03.tar.gz ← qmail展開

[root@centos ~]# cd qmail-1.03 ← qmail展開先ディレクトリへ移動

[root@centos qmail-1.03]# wget http://www.itheart.com/phpgw/qmail-date-localtime.patch
 ← 日本標準時間対応パッチダウンロード

[root@centos qmail-1.03]# wget http://members.elysium.pl/brush/qmail-smtpd-auth/dist/qmail-smtpd-auth-0.31.tar.gz
 ← SMTP-Auth対応パッチダウンロード

[root@centos qmail-1.03]# wget http://qmail.mirrors.summersault.com/qmail-smtpd-relay-reject ← 不正中継拒否対応パッチダウンロード

[root@centos qmail-1.03]# tar zxvf qmail-smtpd-auth-0.31.tar.gz ← SMTP-Auth対応パッチ展開

[root@centos qmail-1.03]# /bin/mv qmail-smtpd-auth-0.31/* . ← SMTP-Auth対応パッチをqmail展開先ディレクトリへ移動

[root@centos qmail-1.03]# patch < qmail-date-localtime.patch ← 日本標準時間対応パッチ施行
patching file date822fmt.c

[root@centos qmail-1.03]# patch < auth.patch ← SMTP-Auth対応パッチ施行
patching file Makefile
patching file TARGETS
patching file qmail-smtpd.8
patching file qmail-smtpd.c

[root@centos qmail-1.03]# patch < qmail-smtpd-relay-reject ← 不正中継拒否対応パッチ施行
patching file qmail-smtpd.c
Hunk #1 succeeded at 56 (offset 3 lines).
Hunk #2 succeeded at 226 (offset 9 lines).
Hunk #3 succeeded at 277 (offset 11 lines).

[root@centos qmail-1.03]# vi error.h ← error.h編集
extern int errno;
↓
#include<errno.h> ← 変更

上記は以下のようなエラーメッセージを出力してインストールが失敗してしまうことの対処
/lib/libc.so.6: could not read symbols: 不正な値です
collect2: ld はステータス 1 で終了しました
make: *** [auto-str] エラー 1

[root@centos qmail-1.03]# make setup check ← qmailインストール
・
・
・
./install
./instcheck

[root@centos qmail-1.03]# ./config-fast `hostname` ← qmail初期設定
Your fully qualified host name is centos.wakuwakustation.com.
Putting centos.wakuwakustation.com into control/me...
Putting wakuwakustation.com into control/defaultdomain...
Putting wakuwakustation.com into control/plusdomain...
Putting centos.wakuwakustation.com into control/locals...
Putting centos.wakuwakustation.com into control/rcpthosts...
Now qmail will refuse to accept SMTP messages except to centos.wakuwakustation.com.
Make sure to change rcpthosts if you add hosts to locals or virtualdomains!

[root@centos qmail-1.03]# echo `hostname -d` >> /var/qmail/control/me ← 自ドメイン名を送信元ドメイン名にする

[root@centos qmail-1.03]# echo `hostname -d` >> /var/qmail/control/rcpthosts ← 自ドメイン名を受信ドメイン名として追加

[root@centos qmail-1.03]# echo `hostname -d` >> /var/qmail/control/locals ← 自ドメイン名をローカルドメイン名として追加

[root@centos qmail-1.03]# cd ← qmail展開先ディレクトリを抜ける

[root@centos ~]# echo "MANPATH /var/qmail/man" >> /etc/man.config
 ← manコマンドでqmailコマンドのマニュアルを参照できるようにする

[root@centos ~]# rm -rf qmail-1.03 ← qmail展開先ディレクトリ削除

[root@centos ~]# rm -f qmail-1.03.tar.gz ← ダウンロードしたqmail削除
※qmailの最新版のURLはqmailダウンロードページで確認すること

(3)checkpasswordインストール
SMTP認証、POP認証に使用するcheckpasswordをインストールする
[root@centos ~]# wget http://cr.yp.to/checkpwd/checkpassword-0.90.tar.gz ← checkpasswordダウンロード

[root@centos ~]# tar zxvf checkpassword-0.90.tar.gz ← checkpassword展開

[root@centos ~]# cd checkpassword-0.90 ← checkpassword展開先ディレクトリへ移動

[root@centos checkpassword-0.90]# vi error.h ← error.h編集
extern int errno;
↓
#include<errno.h> ← 変更

上記は以下のようなエラーメッセージを出力してインストールが失敗してしまうことの対処
/lib/libc.so.6: could not read symbols: 不正な値です
collect2: ld はステータス 1 で終了しました
make: *** [auto-str] エラー 1

[root@centos checkpassword-0.90]# make && make setup check ← checkpasswordインストール
・
・
・
./install
./instcheck

[root@centos checkpassword-0.90]# cd ← checkpassword展開先ディレクトリを抜ける

[root@centos ~]# rm -rf checkpassword-0.90 ← checkpassword展開先ディレクトリ削除

[root@centos ~]# rm -f checkpassword-0.90.tar.gz ← ダウンロードしたcheckpassword削除

[root@centos ~]# chown root:nofiles /bin/checkpassword ← checkpasswordの所有者、所有グループ変更

[root@centos ~]# chmod 4750 /bin/checkpassword ← checkpasswordが所有者権限で動作するように設定
※checkpasswordの最新版のURLはcheckpasswordダウンロードページで確認すること

(4)tcpserverインストール
qmailへのSMTP接続制御を行うため、tcpserverが含まれたucspi-tcpをインストールする
[root@centos ~]# wget http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz ← tcpserverダウンロード

[root@centos ~]# tar zxvf ucspi-tcp-0.88.tar.gz ← ucspi-tcp展開

[root@centos ~]# cd ucspi-tcp-0.88 ← ucspi-tcp展開先ディレクトリへ移動

[root@centos ucspi-tcp-0.88]# vi error.h ← error.h編集
extern int errno;
↓
#include<errno.h> ← 変更

上記は以下のようなエラーメッセージを出力してインストールが失敗してしまうことの対処
/lib/libc.so.6: could not read symbols: 不正な値です
collect2: ld はステータス 1 で終了しました
make: *** [auto-str] エラー 1

[root@centos ucspi-tcp-0.88]# make setup check ← ucspi-tcpインストール
・
・
・
./install
./instcheck

[root@centos ucspi-tcp-0.88]# cd ← ucspi-tcp展開先ディレクトリを抜ける

[root@centos ~]# rm -rf ucspi-tcp-0.88 ← ucspi-tcp展開先ディレクトリ削除

[root@centos ~]# rm -f ucspi-tcp-0.88.tar.gz ← ダウンロードしたucspi-tcp削除

[root@centos ~]# echo '127.:allow,RELAYCLIENT=""' > /etc/tcp.smtp ← 中継許可ホストに自ホストを登録

[root@centos ~]# tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp ← /etc/tcp.smtpをcdb形式に変換
※ucspi-tcpの最新版のURLはucspi-tcpダウンロードページで確認すること

(5)dot-forwardインストール
sendmail用ユーザ別メール転送設定ファイル(~/.forward)をqmailでも利用する場合のみ、dot-forwardをインストールする
※.forwardを使わず、qmailの.forward相当である.qmailを使用する場合はインストールしなくてもよい
[root@centos ~]# wget http://cr.yp.to/software/dot-forward-0.71.tar.gz ← dot-forwardダウンロード

[root@centos ~]# tar zxvf dot-forward-0.71.tar.gz ← dot-forward展開

[root@centos ~]# cd dot-forward-0.71 ← dot-forward展開先ディレクトリへ移動

[root@centos dot-forward-0.71]# vi error.h ← error.h編集
extern int errno;
↓
#include<errno.h> ← 変更

上記は以下のようなエラーメッセージを出力してインストールが失敗してしまうことの対処
/lib/libc.so.6: could not read symbols: 不正な値です
collect2: ld はステータス 1 で終了しました
make: *** [auto-str] エラー 1

[root@centos dot-forward-0.71]# make setup check ← dot-forwardインストール
・
・
・
./instcheck

[root@centos dot-forward-0.71]# cd ← dot-forward展開先ディレクトリを抜ける

[root@centos ~]# rm -rf dot-forward-0.71 ← dot-forward展開先ディレクトリ削除

[root@centos ~]# rm -f dot-forward-0.71.tar.gz ← ダウンロードしたdot-forward削除
※dot-forwardの最新版のURLはdot-forwardダウンロードページで確認すること

(6)fastforwardインストール
sendmail用システム共通メール転送設定ファイル(/etc/aliases)をqmailで利用するのに必要なfastforwardをインストールする
[root@centos ~]# wget http://cr.yp.to/software/fastforward-0.51.tar.gz ← fastforwardダウンロード

[root@centos ~]# tar zxvf fastforward-0.51.tar.gz ← fastforward展開

[root@centos ~]# cd fastforward-0.51 ← fastforward展開先ディレクトリへ移動

[root@centos fastforward-0.51]# vi error.h ← error.h編集
extern int errno;
↓
#include<errno.h> ← 変更

上記は以下のようなエラーメッセージを出力してインストールが失敗してしまうことの対処
/lib/libc.so.6: could not read symbols: 不正な値です
collect2: ld はステータス 1 で終了しました
make: *** [auto-str] エラー 1

[root@centos fastforward-0.51]# make setup check ← fastforwardインストール
・
・
・
./instcheck

[root@centos fastforward-0.51]# cd ← fastforward展開先ディレクトリを抜ける

[root@centos ~]# rm -rf fastforward-0.51 ← fastforward展開先ディレクトリ削除

[root@centos ~]# rm -f fastforward-0.51.tar.gz ← ダウンロードしたfastforward削除

[root@centos ~]# chmod 0 /usr/bin/newaliases ← 旧newaliasesコマンド無効化

[root@centos ~]# mv /usr/bin/newaliases /usr/bin/newaliases.bak ← 旧newaliasesコマンドをリネーム

[root@centos ~]# ln -s /var/qmail/bin/newaliases /usr/bin/newaliases ← newaliasesコマンドをfastforwardに置換え

[root@centos ~]# newaliases ← /etc/aliasesのcdb形式データベース作成

[root@centos ~]# ll /etc/aliases.cdb ← /etc/aliasesのcdb形式データベース作成確認
-rw-r--r--  1 root root 6594 10月 15 14:13 /etc/aliases.cdb

[root@centos ~]# echo "|/var/qmail/bin/fastforward -p -d /etc/aliases.cdb" > /var/qmail/alias/.qmail-default
 ← /etc/aliases.cdbをqmailが参照するように設定
※fastforwardの最新版のURLはfastforwardダウンロードページで確認すること

■qmail設定

(1)qmail設定
[root@centos ~]# echo "10485760" > /var/qmail/control/databytes ← 送受信可能メールサイズを10MB=10*1024*1024に制限
※制限を超えた場合、送信元へエラー通知される

[root@centos ~]# touch /var/qmail/control/doublebounceto ← ダブルバウンスメール※は破棄する
※ダブルバウンスメールとは、送信者・受信者ともに存在しないメールのこと

(2)Maildir形式メールボックス作成
デフォルトでインストールされているsendmailのメール格納形式は共有ディレクトリ形式(「/var/spool/mail/ユーザ名」というファイルに全てのメールが蓄積されていく形式)だが、アクセス性能改善及びセキュリティ強化の観点からqmailデフォルトのMaildir形式へ移行する。

【既存ユーザ対処】
既存ユーザのホームディレクトリにMaildir形式のメールボックスを作成して、蓄積済のメールデータを当該メールボックスへ移行する⇒メールデータ移行を参照

【新規ユーザ対処】
新規ユーザ追加時に自動でホームディレクトリにMaildir形式のメールボックスが作成されるようにする
[root@centos ~]# rm -rf /etc/skel/Maildir

[root@centos ~]# /var/qmail/bin/maildirmake /etc/skel/Maildir

■qmail起動

(1)旧SMTPサーバー停止
SMTPサーバーをqmailに置換えるため、現在起動しているSMTPサーバー(当サイトの場合sendmailまたはPostfix)を停止する。
なお、sendmailまたはPostfixは不要だが、依存しているパッケージが多数あるのでアンインストールはしないようにする
【旧SMTPサーバーがsendmailの場合(デフォルトの場合)】
[root@centos ~]# /etc/rc.d/init.d/sendmail stop ← sendmail停止
sendmailを停止中:                                          [  OK  ]
sm-clientを停止中:                                         [  OK  ]

[root@centos ~]# chkconfig sendmail off ← sendmail自動起動設定解除

[root@centos ~]# chkconfig --list sendmail ← sendmail自動起動設定解除確認
sendmail        0:off   1:off   2:off   3:off   4:off   5:off   6:off ← 全ランレベルのoffを確認

【旧SMTPサーバーがPostfixの場合】
[root@centos ~]# /etc/rc.d/init.d/postfix stop ← Postfix停止
Shutting down postfix:                                     [  OK  ]

[root@centos ~]# chkconfig postfix off ← Postfix自動起動設定解除

[root@centos ~]# chkconfig --list postfix ← Postfix自動起動設定解除確認
sendmail        0:off   1:off   2:off   3:off   4:off   5:off   6:off ← 全ランレベルのoffを確認

(2)sendmailコマンド置換え
CGI等でメール通知に利用するsendmailコマンドをqmailに置換える。
[root@centos ~]# chmod 0 /usr/lib/sendmail ← 旧sendmailコマンド無効化

[root@centos ~]# chmod 0 /usr/sbin/sendmail ← 旧sendmailコマンド無効化

[root@centos ~]# mv /usr/lib/sendmail /usr/lib/sendmail.bak ← 旧sendmailコマンドをリネーム

[root@centos ~]# mv /usr/sbin/sendmail /usr/sbin/sendmail.bak ← 旧sendmailコマンドをリネーム

[root@centos ~]# ln -s /var/qmail/bin/sendmail /usr/lib/sendmail ← sendmailコマンドをqmailに置換え

[root@centos ~]# ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail ← sendmailコマンドをqmailに置換え

(3)qmail起動スクリプト作成
[root@centos ~]# cp /var/qmail/boot/home+df /var/qmail/rc
 ← qmail起動コマンドサンプルを所定の場所へコピー※dot-forward利用する場合

[root@centos ~]# cp /var/qmail/boot/home /var/qmail/rc
 ← qmail起動コマンドサンプルを所定の場所へコピー※dot-forward利用しない場合

[root@centos ~]# sed -i 's/Mailbox/Maildir\//g' /var/qmail/rc ← メールボックス形式をMaildirに変更

[root@centos ~]# yum -y install tcsh ← cシェルインストール

[root@centos ~]# vi /etc/rc.d/init.d/qmail ← qmail起動スクリプト作成
#!/bin/bash
#
# qmail
#
# chkconfig: 2345 80 30
# description: qmail start/stop script

# Source function library.
. /etc/rc.d/init.d/functions

PATH=/var/qmail/bin:/usr/local/bin:/bin:/usr/bin

[ -f /var/qmail/rc ] || exit 0

start() {
    # Start daemons.
    if [ -z $(/sbin/pidof qmail-send) ];  then
        echo -n "Starting qmail"

        # qmail
        csh -cf '/var/qmail/rc &' 2>&1 > /dev/null

        # SMTP
        tcpserver -qv -l0 -HR -u `id -u qmaild` -g `id -g qmaild` \
        -x /etc/tcp.smtp.cdb 0 smtp \
        qmail-smtpd `hostname` /bin/checkpassword /bin/true 2>&1|\
        splogger smtp &

        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch /var/lock/subsys/qmail
        return $RETVAL
    else
        echo "qmail is already started"
    fi
}

stop() {
    # Stop daemons.
    if [ ! -z $(/sbin/pidof qmail-send) ];  then
        echo -n "Shutting down qmail"
        /bin/kill $(/sbin/pidof tcpserver)
        /bin/kill $(/sbin/pidof qmail-send)
        until [ -z $(/sbin/pidof qmail-send) ] && [ -z $(/sbin/pidof tcpserver) ]; do :; done
        echo
        rm -f /var/lock/subsys/qmail
    else
        echo "qmail is not running"
    fi
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        start
        ;;
  status)
        if [ ! -z $(/sbin/pidof qmail-send) ] ;  then
            echo -n "qmail (pid"
            echo -n " `/sbin/pidof qmail-send`"
            echo -n " `/sbin/pidof tcpserver`"
            echo ") is running..."
        else
            echo "qmail is stopped"
        fi
        ;;
   *)
        echo "Usage: qmail {start|stop|restart|status}"
        exit 1
esac

exit 0

[root@centos ~]# chmod +x /etc/rc.d/init.d/qmail ← qmail起動スクリプトへ実行権限付加

(4)qmail起動
[root@centos ~]# /etc/rc.d/init.d/qmail start ← qmail起動
Starting qmail

[root@centos ~]# chkconfig qmail --add ← qmailをchkconfigへ追加

[root@centos ~]# chkconfig qmail on ← qmail自動起動設定

[root@centos ~]# chkconfig --list qmail ← qmail自動起動設定確認
qmail           0:off   1:off   2:on    3:on    4:on    5:on    6:off ← ランレベル2~5のonを確認

(5)ポート開放
ルーター側の設定でポート25番をOPENする。

ポートチェック【外部からポート開放確認】で「host名」にサーバー名(例:wakuwakustation.com)、「port番号」に25と入力して「ポートチェック」ボタン押下し、「ホスト=wakuwakustation.com ポート=25 にアクセスできました。」と表示されることを確認。

■OP25B対策

OP25B(Outbound Port 25 Blocking)対策参照

■qmail-pop3d設定(受信メールサーバーをPOPにする場合)

(1)qmail-pop3d設定
[root@centos ~]# vi /etc/rc.d/init.d/qmail ← qmail起動スクリプト編集
start() {
    # Start daemons.
    if [ -z $(/sbin/pidof qmail-send) ] ;  then
        echo -n "Starting qmail"

        # qmail
        csh -cf '/var/qmail/rc &' 2>&1 > /dev/null

        # SMTP
        tcpserver -qv -l0 -HR -u `id -u qmaild` -g `id -g qmaild` \
        -x /etc/tcp.smtp.cdb 0 smtp rblsmtpd -r relays.ordb.org \
        qmail-smtpd `hostname` /bin/checkpassword /bin/true 2>&1|\
        splogger smtp &

----追加(ここから)----
        # POP3
        tcpserver -qvRH -u `id -u qmaild` -g `id -g qmaild` \
        0 pop3 qmail-popup `hostname` /bin/checkpassword \
        qmail-pop3d Maildir 2>&1 | splogger pop3 &
----追加(ここまで)----

        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch /var/lock/subsys/qmail
        return $RETVAL
    else
        echo "qmail is already started"
    fi
}

[root@centos ~]# /etc/rc.d/init.d/qmail restart ← qmail再起動
Shutting down qmail
Starting qmail

(2)ポート開放
ルーター側の設定でポート110番をOPENする。

ポートチェック【外部からポート開放確認】で「host名」にサーバー名(例:wakuwakustation.com)、「port番号」に110と入力して「ポートチェック」ボタン押下し、「ホスト=wakuwakustation.com ポート=110 にアクセスできました。」と表示されることを確認。

■Dovecotインストール(受信メールサーバーをIMAPにする場合)

[root@centos ~]# yum -y install dovecot ← Dovecotインストール

■Dovecot設定

[root@centos ~]# vi /etc/dovecot.conf ← Dovecot設定ファイル編集
# Protocols we want to be serving: imap imaps pop3 pop3s
# If you only want to use dovecot-auth, you can set this to "none".
#protocols = imap imaps pop3 pop3s
protocols = imap imaps ← 追加

# Location for users' mailboxes. This is the same as the old default_mail_env
# setting. The default is empty, which means that Dovecot tries to find the
# mailboxes automatically. This won't work if the user doesn't have any mail
# yet, so you should explicitly tell Dovecot the full location.
#
# If you're using mbox, giving a path to the INBOX file (eg. /var/mail/%u)
# isn't enough. You'll also need to tell Dovecot where the other mailboxes are
# and where Dovecot can place its index files. This is called the "root mail
# directory", and it must be the first path given in the mail_location setting.
#
# There are a few special variables you can use, eg.:
#
#   %u - username
#   %n - user part in user@domain, same as %u if there's no domain
#   %d - domain part in user@domain, empty if there's no domain
#   %h - home directory
#
# See doc/variables.txt for full list. Some examples:
#
#   mail_location = maildir:~/Maildir
#   mail_location = mbox:~/mail:INBOX=/var/mail/%u
#   mail_location = mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%n
#
# http://wiki.dovecot.org/MailLocation
#
#mail_location =
mail_location = maildir:~/Maildir ← 追加(メールボックス形式をMaildir形式とする)

# ':' separated list of directories under which chrooting is allowed for mail
# processes (ie. /var/mail will allow chrooting to /var/mail/foo/bar too).
# This setting doesn't affect login_chroot or auth_chroot variables.
# WARNING: Never add directories here which local users can modify, that
# may lead to root exploit. Usually this should be done only if you don't
# allow shell access for users. See doc/configuration.txt for more information.
#valid_chroot_dirs =
valid_chroot_dirs = /home ← 追加※OpenSSH+Chrootを導入している場合のみ

■Dovecot起動

(1)Dovecot起動
[root@centos ~]# /etc/rc.d/init.d/dovecot start ← Dovecot起動
Dovecot Imapを起動中:                                      [  OK  ]

[root@centos ~]# chkconfig dovecot on ← Dovecot自動起動設定

[root@centos ~]# chkconfig --list dovecot ← Dovecot自動起動設定確認
dovecot         0:off   1:off   2:on    3:on    4:on    5:on    6:off ← ランレベル2~5のonを確認

(2)ポート143番のOPEN
ルーター側の設定でポート143番をOPENする。

ポートチェック【外部からポート開放確認】で「host名」にサーバー名(例:wakuwakustation.com)、「port番号」に143と入力して「ポートチェック」ボタン押下し、「ホスト=wakuwakustation.com ポート=143 にアクセスできました。」と表示されることを確認。

■メールユーザ追加

(1)メールユーザ追加(SSHによるリモート接続はできないようにする場合)
※例としてユーザ名をcentosとする
[root@centos ~]# useradd -s /sbin/nologin centos ← ユーザ追加

[root@centos ~]# passwd centos ← パスワード設定
Changing password for user centos.
New UNIX password:  ← パスワード応答
Retype new UNIX password:  ← パスワード応答(確認)
passwd: all authentication tokens updated successfully.

(2)メールユーザ追加(SSHによるリモート接続もできるようにする場合)
※例としてユーザ名をcentosとする
[root@centos ~]# useradd centos ← ユーザ追加

[root@centos ~]# passwd centos ← パスワード設定
Changing password for user centos.
New UNIX password:  ← パスワード応答
Retype new UNIX password:  ← パスワード応答(確認)
passwd: all authentication tokens updated successfully.

(3)既存ユーザをメールユーザとする場合
既存ユーザはそのままメールユーザとして使える

■メールソフト設定(受信メールサーバーをPOPにする場合)

自宅や会社等の複数拠点でメールを使用する場合で、メールボックスを同期しなくてもいい場合(例:会社で受信したメールは自宅で受信できなくてもいい場合)、受信メールサーバーにPOPを使用する。
ここでは、メールソフトとしてOutlook Expressを使用する。

Outlook Expressを起動し、メニューの「ツール」⇒「アカウント」⇒「メール」タブ⇒「追加」ボタン⇒「メール」としてメール設定を行う



「表示名」に送信者の名前(任意)を入力して「次へ」




「電子メールアドレス」に送信者のメールアドレス(例:centos@wakuwakustation.com)を入力して「次へ」




「受信メールサーバー」にメールサーバー名(例:mail.wakuwakustation.com)を入力
「送信メールサーバー」にメールサーバー名(例:mail.wakuwakustation.com)を入力して「次へ」




「パスワード」にパスワードを入力して「次へ」




「完了」




追加したアカウントをダブルクリックしてプロパティを開く




「サーバー」タブの「このサーバーは認証が必要」をチェック




「OK」



■メールソフト設定(受信メールサーバーをIMAPにする場合)

自宅や会社等の複数拠点でメールを使用する場合で、メールボックスを同期したい場合(例:会社で受信したメールを自宅でも受信したい場合)、受信メールサーバーにIMAPを使用する。
ここでは、メールソフトとしてOutlook Expressを使用する。

Outlook Expressを起動し、メニューの「ツール」⇒「アカウント」⇒「メール」タブ⇒「追加」ボタン⇒「メール」としてメール設定を行う



「表示名」に送信者の名前(任意)を入力して「次へ」




「電子メールアドレス」に送信者のメールアドレス(例:centos@wakuwakustation.com)を入力して「次へ」




「受信メールサーバーの種類」で「IMAP」を選択
「受信メールサーバー」にメールサーバー名(例:mail.wakuwakustation.com)を入力
「送信メールサーバー」にメールサーバー名(例:mail.wakuwakustation.com)を入力して「次へ」




「パスワード」にパスワードを入力して「次へ」




「完了」




追加したアカウントをダブルクリックしてプロパティを開く




「サーバー」タブの「このサーバーは認証が必要」をチェック




「IMAP」タブ
「送信済みアイテムのパス」に「Sent」と入力
「下書きのパス」に「Drafts」と入力して「OK」




「はい」




「OK」



■メールサーバー確認

・内部で同一ユーザ同士でメールの送受信
・内部で他ユーザ間でメールの送受信
・内部で外部(プロバイダのメールアドレス等)との送受信
・内部で携帯との送受信※
・外部(会社等)で同一ユーザ同士でメールの送受信
・外部(会社等)で他ユーザ間でメールの送受信
・外部(会社等)で外部(プロバイダのメールアドレス等)との送受信
・外部(会社等)で携帯との送受信※

※携帯はドメイン指定受信等でメールサーバーからのメールが拒否されないようにしておくこと

■メール不正中継拒否テスト

RBL.JPで「ホスト名」に自宅サーバーのホスト名(例:wakuwakustation.com)を入力して「Check」ボタンを押下する。
19種類のテストが行われ、ページ最後尾にno relays accepted.と表示されればOK。