CentOS サーバー構築マニュアル

home > CentOS5 > Postfix Dovecot インストール

Postfix Dovecot インストール




■Postfixインストール
[root@ns1 ~]# yum -y install postfix
[root@ns1 ~]# yum clean packages

■Postfix設定
[root@ns1 ~]# cp /etc/postfix/main.cf /etc/postfix/main.cf.org
[root@ns1 ~]# vi /etc/postfix/main.cf

#myhostname = host.domain.tld
↓
myhostname = ns1.centos.orz ←コメント解除&変更(完全修飾ドメイン名を指定)

#mydomain = domain.tld
↓
mydomain = centos.orz ←コメント解除&変更(ドメイン名を指定)

#myorigin = $mydomain
↓
myorigin = $mydomain ←コメント解除(メールに表示される@以降のドメイン名)

inet_interfaces = localhost
↓
inet_interfaces = all ←変更(外部からのメール受信を許可)

mydestination = $myhostname, localhost.$mydomain, localhost
↓
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain ←変更(左記のドメインを受信可能にする)

#home_mailbox = Maildir/
↓
home_mailbox = Maildir/ ←コメント解除(メールボックスをMaildir形式にする)

#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
↓
smtpd_banner = $myhostname ESMTP unknown ←コメント解除&変更(メールサーバーの情報を隠す)

↓最終行に下記を追加
# Cyrus-SASL configuration
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
broken_sasl_auth_clients = yes
message_size_limit = 10485760
※黄色い部分は環境に合わせて変更してください。

ヒント ヒント

smtpd_sasl_auth_enable = yes ←SASLによるSMTP-Authを許可する
smtpd_sasl_local_domain = $myhostname ←realmを設定する
smtpd_sasl_security_options = noanonymous ←匿名ログインを許可しない
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination ←リレー許可を設定
broken_sasl_auth_clients = yes ←AUTHコマンドを認識できないメールソフトに対応させる
message_size_limit = 10485760 ←受信できる最大サイズを設定

■SMTP-Auth設定 (※pam認証の場合)
[root@ns1 ~]# /etc/rc.d/init.d/saslauthd start
[root@ns1 ~]# chkconfig saslauthd on
[root@ns1 ~]# chkconfig --list saslauthd
saslauthd       0:off   1:off   2:on    3:on    4:on    5:on    6:off

■SMTP-Auth設定 (※sasldb2認証の場合)
vi /usr/lib/sasl2/smtpd.conf

pwcheck_method: saslauthd
↓
pwcheck_method: auxprop ←変更
[root@ns1 ~]# echo 'hoge54321' | saslpasswd2 -p -c -u ns1.centos.orz hoge [root@ns1 ~]# sasldblistusers2 hoge@ns1.centos.orz: userPassword [root@ns1 ~]# chgrp postfix /etc/sasldb2 [root@ns1 ~]# ll /etc/sasldb2 -rw-r----- 1 root postfix 12288 1月 1 10:10 /etc/sasldb2
※黄色い部分は環境に合わせて変更してください。

ヒント ヒント

「saslpasswd2 -c -u ドメイン名(realm) ユーザー名」でユーザーを追加します。
「-d」オプションでユーザーを削除します。(例:saslpasswd2 -d hoge@ns1.centos.orz)
「sasldblistusers2」でユーザーを確認することができます。
「chgrp postfix /etc/sasldb2」(所属グループの変更)は初回のみで構いません。

■sendmail停止
[root@ns1 ~]# /etc/rc.d/init.d/sendmail stop
[root@ns1 ~]# chkconfig sendmail off
[root@ns1 ~]# alternatives --config mta
2 プログラムがあり 'mta'を提供します。

  選択       コマンド
-----------------------------------------------
*+ 1           /usr/sbin/sendmail.sendmail
   2           /usr/sbin/sendmail.postfix

Enterを押して現在の選択[+]を保持するか、選択番号を入力します:2 ←2を入力してエンター

■Postfix起動
[root@ns1 ~]# /etc/rc.d/init.d/postfix start
[root@ns1 ~]# chkconfig postfix on
[root@ns1 ~]# chkconfig --list postfix
postfix         0:off   1:off   2:on    3:on    4:on    5:on    6:off

■Dovecotインストール
[root@ns1 ~]# yum -y install dovecot
[root@ns1 ~]# yum clean packages

■dovecot.conf編集
[root@ns1 ~]# cp /etc/dovecot.conf /etc/dovecot.conf.org
[root@ns1 ~]# vi /etc/dovecot.conf

#protocols = imap imaps pop3 pop3s
↓
protocols = imap imaps pop3 pop3s ←コメント解除(imap imaps pop3 pop3s対応)

#mail_location =
↓
mail_location = maildir:~/Maildir ←コメント解除&変更(メールボックスをMaildir形式にする)

■dovecot起動
[root@ns1 ~]# /etc/rc.d/init.d/dovecot start
[root@ns1 ~]# chkconfig dovecot on
[root@ns1 ~]# chkconfig --list dovecot
dovecot         0:off   1:off   2:on    3:on    4:on    5:on    6:off

■新規ユーザー用メールディレクトリ作成
[root@ns1 ~]# mkdir -p /etc/skel/Maildir/new
[root@ns1 ~]# mkdir -p /etc/skel/Maildir/cur
[root@ns1 ~]# mkdir -p /etc/skel/Maildir/tmp
[root@ns1 ~]# chmod -R 700 /etc/skel/Maildir/



■POP3接続確認
[root@ns1 ~]# telnet localhost 110

Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
+OK Dovecot ready.
USER hoge
+OK
PASS hoge12345
+OK Logged in.
LIST
+OK 0 messages:
.
QUIT
+OK Logging out.
Connection closed by foreign host.
※黄色い部分は環境に合わせて変更してください。

■BASE64エンコードでパスワード作成
[root@ns1 ~]# perl -MMIME::Base64 -e 'print encode_base64("hoge\0hoge\0hoge12345");'
aG9nZQBob2dlAGhvZ2UxMjM0NQ==

■SMTP接続確認
[root@ns1 ~]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 ns1.centos.orz ESMTP unknown
EHLO localhost
250-ns1.centos.orz
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
AUTH PLAIN aG9nZQBob2dlAGhvZ2UxMjM0NQ==
235 2.0.0 Authentication successful
QUIT
221 2.0.0 Bye
Connection closed by foreign host.
※黄色い部分は環境に合わせて変更してください。

ヒント ヒント

SMTP-Auth確認の際、BASE64エンコードで作成されたパスワードを使用します。
encode_base64()の書式は encode_base64("ユーザー名\0ユーザー名\0パスワード")

■Outlook Express設定
Outlook Express設定
「ツール」>「アカウント」をクリック。


Outlook Express設定
「追加」>「メール」をクリック。


Outlook Express設定
「表示名」を記入して「次へ」をクリック。


Outlook Express設定
「電子メールアドレス」を記入して「次へ」をクリック。


Outlook Express設定
受信メールサーバー、送信メールサーバーのIPアドレスまたはホスト名を記入して「次へ」をクリック。
※ここでは例として「192.168.3.10」を記入しています。


Outlook Express設定
アカウント名とパスワードを記入して「次へ」をクリック。
※ここでは例として「アカウント名 hoge」「パスワード hoge12345」を記入しています。


Outlook Express設定
「完了」をクリック。


Outlook Express設定
「プロパティ」をクリック。


Outlook Express設定
「このサーバーは認証が必要」にチェックを入れて「適用」をクリック。


Outlook Express設定
SMTP-AUTHで別のアカウントを使用する場合は「設定」をクリック。


Outlook Express設定
「次のアカウントとパスワードでログオンする」を選択。
SMTP-Auth用のアカウントとパスワードを記入して「OK」をクリック。
※ここでは例として「アカウント hoge」「パスワード hoge54321」を記入しています。


Outlook Express設定
「OK」をクリック。


Outlook Express設定
「閉じる」をクリック。

外部に公開する場合 外部に公開する場合

プロトコル(TCP)ポート25番(SMTP)を開放。
プロトコル(TCP)ポート110番(POP3)を開放。
プロトコル(TCP)ポート143番(IMAP)を開放。



Home PageTop Forum Last updated 2008-05-12

Copyright centos.server-manual.com このサイトはリンクフリーです。ご自由にリンクしてください。