メールサーバの構築 Edit

  • はじめに
    以下のプログラムを使用してメール環境を構築したときのメモを記します。
    • SMTPサーバ … postfix Maildir形式で運用 (OSXに付属)
    • IMAPサーバ … dovecot
    • IMAPクライアント … Mail.app(OSXに付属)
    • WEBメール … SquirrelMail

  • 注意事項
    SquirrelMailの節では、HTTPSではなく、通常のHTTPプロトコルを用いたWEBメール環境を構築します。従って、インターネット上を平文のまま、パスワードやメール本文が送信されることを、ご留意ください。万が一に備え、WEBメール専用のアカウントでの使用をお勧めします。
    (そうは言っても、それほど神経質にならなくても良いと思いますけど。)

Postfix Edit

  • Postfixの設定方針
    • 直接、インターネットへメールの送受信が行えるよう設定を行います。
      (デフォルトでは送受信できないよう設定されているため。)
    • Maildir形式(メール1通、1ファイル形式)で運用します。

  • Postfixの設定
    • /etc/hostconfig
      下記を最下行に追加します。
      MAILSERVER=-YES-
      
  • /etc/postfix/main.cf
    --- /etc/postfix/main.cf.orig	2008-08-10 16:53:32.000000000 +0900
    +++ /etc/postfix/main.cf	2009-09-06 15:11:57.000000000 +0900
    @@ -1,3 +1,11 @@
    +# my setting
    +myhostname = eggplant.ddo.jp    自身のドメインを指定
    +mydomain = eggplant.ddo.jp    自身のドメインを指定
    +inet_interfaces = all
    +mydestination = $myhostname, localhost.$mydomain, $mydomain
    +home_mailbox = Maildir/
    +relayhost = [xxxx.ocn.ne.jp]    プロバイダのSMTPサーバを指定
    +
     # Global Postfix configuration file. This file lists only a subset
     # of all parameters. For the syntax, and for a complete parameter
     # list, see the postconf(5) manual page (command: "man 5 postconf").
    
  • $HOME/Maildir
    メール受信時、自動で作成されるみたいなので特に作成する必要は無いみたいです。

  • Postfixの起動&動作確認
  • /System/Library/LaunchDaemons/org.postfix.master.plist
    Tigerの設定をそのまま使用します。
    --- /System/Library/LaunchDaemons/org.postfix.master.plist.orig	2008-08-10 17:18:14.000000000 +0900
    +++ /System/Library/LaunchDaemons/org.postfix.master.plist	2008-08-10 17:27:49.000000000 +0900
    @@ -9,12 +9,12 @@
     	<key>ProgramArguments</key>
     	<array>
     		<string>master</string>
    -		<string>-e</string>
    -		<string>60</string>
     	</array>
     	<key>QueueDirectories</key>
     	<array>
     		<string>/var/spool/postfix/maildrop</string>
     	</array>
    +	<key>OnDemand</key>
    +	<false/>
     </dict>
     </plist>
    
  • 起動
    $ sudo launchctl start org.postfix.master
    
  • ルータ設定 … SMTP(Port25)のフォワード
    インターネット経由でメールの送受信を行えるよう、ADSLモデム(ルータ)のポート設定を行います。
    具体的には、smtpポート(25番)をMac miniへフォワードするように設定します。
    ADSLモデムの設定変更やリセットでWAN側IPアドレスが変化する環境の方は、
    DynamicDNSの更新も同時に行ってくださいね。私はこれに気付かず、随分はまりました。

  • 動作確認
    • 他のマシンからOSXのユーザへメールを送信、
    • ユーザの$HOMEにMaildirディレクトリが作成されていることを確認、
    • $HOME/Maildir/new の下にメールが届いていることを確認すればOKです。

dovecot -- IMAP/POP3サーバ Edit

  • dovecot本家サイト
  • インストール
    MacPortsに用意されているので、それを入れちゃいます。
    Macmini:~ user$ sudo port install dovecot
    
  • PAM認証の設定(leopard)
    sshdの設定を流用。
    Macmini:~ user$ sudo cp /etc/pam.d/sshd /etc/pam.d/dovecot
    
  • PAM認証の設定(snow leopard)
    ftpdの設定を流用。
    Linux PAM から Open PAM へ変更されたことに伴う変更
    Macmini:~ user$ sudo cp /etc/pam.d/ftpd /etc/pam.d/dovecot
    

  • /opt/local/etc/dovecot/dovecot.conf
    dovecot-example.confをコピーして、
    Macmini:~ user$ cd /opt/local/etc/dovecot
    Macmini:/opt/local/etc/dovecot user$ sudo cp dovecot-example.conf dovecot.conf
    
    次の箇所を変更します。
    (SSLをとりあえずディセーブル。今後の課題)
    --- dovecot-example.conf        Sat Jul 30 14:17:52 2005
    +++ dovecot.conf        Sat Jul 30 15:19:30 2005
    @@ -16,6 +16,7 @@
     # Protocols we want to be serving:
     #  imap imaps pop3 pop3s
     #protocols = imap imaps
    +protocols = imap pop3
     
     # IP or host address where to listen in for connections. It's not currently
     # possible to specify multiple addresses. "*" listens in all IPv4 interfaces.
    @@ -31,7 +32,7 @@
     #ssl_listen =
     
     # Disable SSL/TLS support.
    -#ssl_disable = no
    +ssl_disable = yes
     
     # PEM encoded X.509 SSL/TLS certificate and private key. They're opened before
     # dropping root privileges, so keep the key file unreadable by anyone but
    
  • /opt/local/var/run/dovecot
    Macmini:/usr/local/etc user$ sudo mkdir -p /opt/local/var/run/dovecot
    

  • /etc/hostconfig
    最終行へ追加
    DOVECOT=-YES-
    
  • 起動方法等
    ブート時に自動でdovecotが起動します。
    なお、手動でデーモンを起動/停止/再起動するには、次のようにします。
    Macmini:~ user$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.dovecot.plist
    

  • 補足…MacOSX付属のMail.appからアクセスするには?
    Mail.appを起動して、環境設定→アカウントへ、localhostのIMAPサーバを指定すればOK!

SquirrelMail -- WEBメール Edit

  • ソースダウンロード
  • インストール
    /Users/www/Sites/webmailへインストールします。
    $ cd /Users/www/Sites
    $ sudo tar vxfzp squirrelmail-1.4.19-ja-20090522.tar.gz
    $ sudo mv squirrelmail-1.4.19-ja webmail
    $ sudo tar vxfz ja_JP-1.4.18-20090526.tar.gz -C webmail
    
  • work directryの設定
    $ sudo mkdir -p /var/local/squirrelmail
    $ cd /var/local/squirrelmail
    $ sudo mkdir attach
    $ sudo chgrp -R www attach
    $ sudo chmod 730 attach
    
  • owner設定
    Macmini:/Users/www/Sites user$ sudo chown -R www:www webmail
    
  • SquirrelMailの設定
    Macmini:/Users/www/Sites user$ sudo ./webmail/config/conf.pl
    
    • 2. Server Setting
      • 1. Domain → eggplant.ddo.jp 自身のドメインを指定。
    • 10. Languages
      • 1. Default Language → ja_JP
      • 2. Defailt Charset → iso-2022-jp
    • Q. Quit → 設定を保存します。

  • phpの設定
    • 次のようなメッセージが多量に出力されるのでその対策を行う。
      Warning: date() [function.date]: It is not safe to rely on the system's
      timezone settings. You are *required* to use the date.timezone setting or the
      date_default_timezone_set() function. In case you used any of those methods and
      you are still getting this warning, you most likely misspelled the timezone
      identifier. We selected 'Asia/Tokyo' for 'JST/9.0/no DST' instead ...
      
    • 対策
      $ cd /etc
      $ sudo cp php.ini.default php.ini
      $ sudo chmod +w php.ini
      
    • php.iniの編集
      --- php.ini.default	2009-12-31 16:13:19.000000000 +0900
      +++ php.ini	2009-12-31 16:10:23.000000000 +0900
      @@ -994,7 +994,7 @@ default_socket_timeout = 60
       [Date]
       ; Defines the default timezone used by the date functions
       ; http://php.net/date.timezone
      -;date.timezone =
      +date.timezone = 'Asia/Tokyo'
       
       ; http://php.net/date.default-latitude
       ;date.default_latitude = 31.7667
      
  • Apacheの設定
    • /etc/httpd/users/www.confへ以下を追加します。
      Alias /webmail /Users/www/Sites/webmail
      <Directory /Users/www/Sites/webmail>
          AllowOverride none
      </Directory>
      
    • Apacheの再起動
      まず、confファイルの文法チェックを行い、
      Macmini:~ user$ sudo apachectl configtest
      Processing config directory: /private/etc/httpd/users/*.conf
       Processing config file: /private/etc/httpd/users/www.conf
      Syntax OK
      
      再起動
      Macmini:~ user$ sudo apachectl restart
      
  • 動作確認
    • ブラウザから、ログインできるか確認します。
      http://IP_ADDRESS/webmail/
      
      squirrelmail.png

    • 個人情報等の設定
      ログイン後、オプション→個人情報の下記項目を設定しておくと良いでしょう。
      • フルネーム
      • メールアドレス
      • 返信先を設定



添付ファイル: filesquirrelmail.png 217件 [詳細]

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2009-12-31 (木) 16:43:04 (5235d)