AFP経由のrsync MaximaのインストールとMaximaPHPの導入
3 月 31

なかなかバーチャルユーザーでのメールサーバーがうまくいかないので、まずはLinuxユーザーでのメール送受信をしてみました。(今回は成功しています。)

構成はPostfix(とりあえずSSLなしのSMTP) + SASL2によるSMTP-Auth + OP25B対策のためISP(eo)のサーバーを経由 + Courier(IMAP,POP) よってMaildir形式です。いたって標準的な構成です。
外部に解放するポートは
送信に必須(25,587)
WANからSSLなしでメールチェックをする場合に必要(110,143)
WANからSSLありでメールチェックをする場合に必要(995,993)
です。

必要なものをインストールします。

$ su
# apt-get install postfix postfix-tls libsasl2 libsasl2-modules sasl2-bin courier-pop-ssl courier-imap-ssl

courierではWebによる設定(courier-webadmin)について聞かれます。Webベースで設定できるのならそうしておきたいので私は「はい」を選択しておきましたがどちらでもかまいません。
Postfixのインストール時にサーバーのタイプを聞かれますので「インターネットサイト」を選択してください。
「メール名は?」と聞かれたら構築するメールサーバーの「@」以降を入力してください。

では、Postfixの設定ファイルを編集します。
ますは「/etc/postfix/main.cf」を。
0.基本的な変更

mydomain = hogehoge.com

を追記。(これは適時書き換えてください)

myorigin = mail.hogehoge.net
mydestination = $myhostname, localhost.$mydomain, localhost

に変更
1.Maildir形式にする。

mailbox_command = procmail -a "$EXTENSION"

#mailbox_command = procmail -a "$EXTENSION"

としてコメントアウト

home_mailbox = Maildir/

を追加
2.SASL2によるSMTP-Authの有効

smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_auth_destination,reject
smtpd_sasl_path = smtpd
broken_sasl_auth_clients = yes

を追加
3.OP25B対策のためISPのSMTPを経由するように変更

relayhost = 

relayhost = [smtpauth.eonet.ne.jp]:587

に。これはISPのSMTP-Authサーバーのアドレスにしてください。

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/isp_auth
smtp_sasl_security_options = noanonymous

を追加。

次に「/etc/postfix/master.cf」を編集
「smtp inet n - - - - smtpd」の下に

  -o smtpd_sasl_auth_enable=yes

を追加(最初のスペースは不可欠)

#submission inet n       -       -       -       -       smtpd
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject

submission inet n       -       -       -       -       smtpd
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject

に変更(コメント解除)し、その下に

  -o smtpd_etrn_restrictions=reject

を追加。

ISPのメールサーバーにログインするためのユーザー名とパスワードを登録します。
「/etc/postfix/isp_auth」を作成し以下のように記述して保存します。

[smtpauth.eonet.ne.jp]:587 ユーザー名:パスワード

そしてDB化

# postmap /etc/postfix/isp_auth

最後にSASLにSMTPのユーザー名とパスワードを登録します。

# saslpasswd2 -c -u `postconf -h myhostname` ユーザー名

パスワードを二回聞かれるのでSMTP認証に使いたいパスワードを設定してください。
初回時に以下のコマンドも実行してください。

# chgrp postfix /etc/sasldb2
# chmod g+r /etc/sasldb2
# ln /etc/sasldb2 /var/spool/postfix/etc

ユーザーを削除するときは

# saslpasswd2 -c -u `postconf -h myhostname` ユーザー名

これでLinuxユーザー名とパスワードでメール送受信ができるはずです。
POPのパスワードはLinuxユーザーのパスワードを利用し,SMTPへはSASLで設定したパスワードを利用します。

トラックバックURL : http://blog.chibiegg.net/2008/03/31_17_135.htm/trackback

コメントお待ちしております