ServersMan@VPS(CentOS)にPostfixをインストール
以下、書きかけ
ServersMan@VPS(CentOS)にPostfixをインストールしメールサーバーを構築してみました。(Postfixの設定にはWebminを使用)
1.Postfixのインストール
yum install postfix
2.インストールが完了しているか確認
# rpm -qa postfix
postfix-2.6.6-2.2.el6_1.x86_64
3.main.cfの編集
# vi /etc/postfix/main.cf : # INTERNET HOST AND DOMAIN NAMES # # The myhostname parameter specifies the internet hostname of this # mail system. The default is to use the fully-qualified domain name # from gethostname(). $myhostname is used as a default value for many # other configuration parameters. # #myhostname = host.domain.tld #myhostname = virtual.domain.tld myhostname = mail.chamu.org ←サーバのホスト名 # The mydomain parameter specifies the local internet domain name. # The default is to use $myhostname minus the first component. # $mydomain is used as a default value for many other configuration # parameters. # #mydomain = domain.tld mydomain = chamu.org ←ドメイン名 # SENDING MAIL # # The myorigin parameter specifies the domain that locally-posted # mail appears to come from. The default is to append $myhostname, # which is fine for small sites. If you run a domain with multiple # machines, you should (1) change this to $mydomain and (2) set up # a domain-wide alias database that aliases each user to # user@that.users.mailhost. # # For the sake of consistency between sender and recipient addresses, # myorigin also specifies the default domain name that is appended # to recipient addresses that have no @domain part. # #myorigin = $myhostname #myorigin = $mydomain myorigin = $mydomain ←追加 # RECEIVING MAIL # The inet_interfaces parameter specifies the network interface # addresses that this mail system receives mail on. By default, # the software claims all active interfaces on the machine. The # parameter also controls delivery of mail to user@[ip.address]. # # See also the proxy_interfaces parameter, for network addresses that # are forwarded to us via a proxy or network address translator. # # Note: you need to stop/start Postfix when this parameter changes. # #inet_interfaces = all #inet_interfaces = $myhostname #inet_interfaces = $myhostname, localhost #inet_interfaces = localhost ←コメントアウト inet_interfaces = all ←追加 : # Specify a list of host or domain names, /file/name or type:table # patterns, separated by commas and/or whitespace. A /file/name # pattern is replaced by its contents; a type:table is matched when # a name matches a lookup key (the right-hand side is ignored). # Continue long lines by starting the next line with whitespace. # # See also below, section "REJECTING MAIL FOR UNKNOWN LOCAL USERS". # mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain ←追加 #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, # mail.$mydomain, www.$mydomain, ftp.$mydomain : DELIVERY TO MAILBOX # # The home_mailbox parameter specifies the optional pathname of a # mailbox file relative to a user's home directory. The default # mailbox file is /var/spool/mail/user or /var/mail/user. Specify # "Maildir/" for qmail-style delivery (the / is required). # #home_mailbox = Mailbox #home_mailbox = Maildir/ home_mailbox = Maildir/ ←追加 : # SHOW SOFTWARE VERSION OR NOT # # The smtpd_banner parameter specifies the text that follows the 220 # code in the SMTP server's greeting banner. Some people like to see # the mail version advertised. By default, Postfix shows no version. # # You MUST specify $myhostname at the start of the text. That is an # RFC requirement. Postfix itself does not care. # #smtpd_banner = $myhostname ESMTP $mail_name #smtpd_banner = $myhostname ESMTP $mail_name ($mail_version) smtpd_banner = $myhostname ESMTP unknown ←追加 : # SMTP Auth ←ファイルの最後に追加 smtpd_sasl_auth_enable = yes smtpd_sasl_local_domain = $myhostname smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination
4.master.cfの編集
587番ポートでもメール出来るようにするには、vi /etc/postfix/master.cfコマンドで
# vi /etc/postfix/master.cf #submission inet n - n - - smtpd # -o smtpd_enforce_tls=yes # -o smtpd_sasl_auth_enable=yes # -o smtpd_client_restrictions=permit_sasl_authenticated,reject
の部分を以下に変更
submission inet n - n - - smtpd # -o smtpd_enforce_tls=yes -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject
5.SASLによるSMTP認証用MD5パッケージとplainパッケージのインストール
yum install cyrus-sasl-md5 cyrus-sasl-plain
6.Postfixの起動
(1)sendmail停止
# /etc/rc.d/init.d/sendmail stop # chkconfig sendmail off
(2)メールサーバー切替え
# alternatives --config mta 2 プログラムがあり 'mta' を提供します。 選択 コマンド ----------------------------------------------- *+ 1 /usr/sbin/sendmail.sendmail 2 /usr/sbin/sendmail.postfix Enter を押して現在の選択 [+] を保持するか、選択番号を入力します:2
# service postfix start # chkconfig postfix on # chkconfig saslauthd on #chkconfig --list postfix postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off # chkconfig --list saslauthd saslauthd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
yum install dovecot
8.インストールが完了しているか確認
# rpm -qa dovecot
dovecot-2.0.9-5.el6.x86_64
9.dovecot.confを編集
vi /etc/dovecot/dovecot.conf : # Should each login be processed in it's own process (yes), or should one # login process be allowed to process multiple connections (no)? Yes is more # secure, espcially with SSL/TLS enabled. No is faster since there's no need # to create processes all the time. #login_process_per_connection = yes login_process_per_connection = no ←追加 : # See doc/wiki/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 # # <doc/wiki/MailLocation.txt> # #mail_location = mail_location = maildir:~/Maildir ←追加
10.Dovecotの起動・起動設定
chkconfig --list dovecot dovecot 0:off 1:off 2:off 3:off 4:off 5:off 6:off 自動起動が「of」なので # chkconfig dovecot on [root@dti-vps-srv30 ~]# chkconfig --list dovecot dovecot 0:off 1:off 2:on 3:on 4:on 5:on 6:off Dovecotの起動 # service dovecot start Dovecot Imap を起動中: [ OK ] # netstat -antup | egrep 'master|dovecot' tcp 0 0 0.0.0.0:587 0.0.0.0:* LISTEN 23897/master tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 23897/master tcp 0 0 :::993 :::* LISTEN 24007/dovecot tcp 0 0 :::995 :::* LISTEN 24007/dovecot tcp 0 0 :::110 :::* LISTEN 24007/dovecot tcp 0 0 :::143 :::* LISTEN 24007/dovecot
4.Postfix および DovecotモジュールのWebminへの登録
「Webmin 設定」の「モジュールのリフレッシュ」により、インストールされたサーバに関するすべてのWebminモジュールを再確認し、Postfix および DovecotモジュールをWebminへ登録します。
5.Postfix の設定
Webminの「サーバ」→「Postfix の設定」→「一般オプション」画面で、以下の各項目を、各自のネットワーク環境に合わせて、下記内容などに変更。
設定する項目 | 設定内容 |
発信メールで使用するドメイン | 「ドメイン名を使用」をチェック |
メールを受信するドメイン | $myhostname, localhost.$mydomain, localhost, $mydomain |
メール受信用のネットワーク インターフェイス | 「すべて」をチェック |
このメール システムのインターネット ホスト名 | mail.chamu.org |
ローカル インターネット ドメイン名 | chamu.org |
ローカル ネットワーク | 183.181.10.26/32,28.178.88.0/24,127.0.0.0/8 |
Webminの「サーバ」→「Postfix の設定」→「ローカル配信」画面の
「ユーザ メールボックス ファイルのホーム相対パス名」の項目を「Maildir/」に変更。
Webminの「サーバ」→「Postfix の設定」→「SMTP サーバ オプション」画面の
「SMTP グリーティング バナー」の項目を「$myhostname ESMTP unknown」に
「宛先アドレスの制限」の項目を「permit_mynetworks permit_sasl_authenticated reject_unauth_destination」に変更。
Webminの「サーバ」→「Postfix の設定」→「SMTP 認証と暗号化」画面の
「SASL SMTP 認証を有効にしますか?」の項目を「はい」に変更。
5.Postfix の起動、終了
Webminの「サーバ」→「Postfix の設定」画面で、「Postfixを開始」ボタンをクリックすると、Postfixが起動します。Postfixの終了も同様。
なお、ServersMan@VPSでは認証デーモン、saslauthdが自動起動する設定なので、特に設定の必要はありません。