*Cyrus-IMAP [#f94c092f]

RIGHT:更新日&lastmod();  

**IMAPサーバのCyrus-IMAPをrpmでインストール。 [#y6e04bcc]

Cyrus-IMAPはCourier-IMAPと比べユーザの認証をlogin認証と分離することができる。~

rpmで必要なパッケージのインストール

 # apt-get install cyrus-imapd cyrus-imapd-utils cyrus-sasl cyrus-sasl-plain cyrus-sasl-md5 perl-Cyrus

***環境設定 [#ka07fe43]
sieveというシステムでメールを振り分ける。ユーザーのホームディレクトリに.sieveというファイルを作成して利用する方式とサーバにスクリプトおいて振り分ける方式の2種類があるが、今回はユーザーのホームディレクトリに.sieveというファイルを作成して利用する方式で行う。~
認証方式もいろいろあるがOutLookExpressで利用できるようにするにはプレーンテキスト形式にも対応できるように設定~


/etc/imapd.conf

 #Cyrus IMAP Serverが各種管理用ファイルを置くディレクトリ
 configdirectory: /var/lib/imap
 
 # ユーザーのメールの保管場所
 partition-default: /var/spool/imap
 
 管理者ユーザー
 ##admins: cyrus
 admins: admin
 
 #/home/USER/.sieve でメールの振り分け処理
 sievedir: /var/lib/imap/sieve
 sendmail: /usr/sbin/sendmail
 hashimapspool: true
 
 # =======================================
 #サーバにスクリプトおいて振り分ける方式
 # sieveスクリプトの保管場所
 # sievedir: /var/lib/imap/sieve
 # =======================================
 
 # 認証方法の指定。
 ##sasl_pwcheck_method: saslauthd
 sasl_pwcheck_method: auxprop  <==これを選択
 ##sasl_pwcheck_method: sasldb
 sasl_mech_list: PLAIN, cram-md5, digest-md5
  
 # TLS関係の設定 
 tls_cert_file: /usr/share/ssl/certs/cyrus-imapd.pem
 tls_key_file: /usr/share/ssl/certs/cyrus-imapd.pem
 tls_ca_file: /usr/share/ssl/certs/ca-bundle.crt

変更後

 # /etc/rc.d/init.d/cyrus-imapd start

で起動

その他プレーンテキスト認証は/usr/lib/sasl2/smtpd.confに「pwcheck_method: auxprop」を追加ともあるが、imap.confで指定したらいらなかった。


''popやその他のサービスをコントロール''~

/etc/cyrus.confに起動させるサービスが記入されているので必要に応じ編集するがとえいあえずデフォルトで行う

***ユーザの登録 [#v25ed2ed]

 ユーザーの追加/パスワード変更 : saslpasswd2 ユーザー名
 ユーザーの削除 : saslpasswd2 -d ユーザー名
 ユーザーの一覧表示 : sasldblistusers2

 # /usr/sbin/saslpasswd2 okada
 Password:
 Again (for verification):

''管理者ユーザー(imap.confで定義した)の登録(必須)''~
 # /usr/sbin/saslpasswd2 admin
 Password:
 Again (for verification):

''ユーザ一覧''~
 # /usr/sbin/sasldblistusers2
 okada@localhost.localdomain: userPassword
 admin@localhost.localdomain: userPassword

ユーザがいないときは
 listusers failed
と表示される

&color(red){注)ユーザ登録時に/var/log/messagesに以下のエラーが出る(原因不明)};~

 Sep 21 17:37:11 localhost saslpasswd2: setpass succeeded for okada
 Sep 21 17:37:11 localhost saslpasswd2: error deleting entry from sasldb:
 DB_NOTFOUND: No matching key/data pair found

***メールボックスの管理 [#rca0f545]

''メールボックスの作成''
このとき、/etc//sasldb2にアクセス権がないと「セグメンテーション違反」のエラーが出るので、オーナーの変更を行う

 # chown cyrus. /etc/sasldb2

adminでloginして、メールボックスを作成
 $ cyradm --user admin localhost
 Password:
 localhost.localdomain> cm user.okada
 localhost.localdomain> lm     <=メールボックスの確認
 user.okada (\HasNoChildren)

**postfixの変更 [#bed49f43]
''main.cf''
 #mailbox_transport = lmtp:unix:/file/name
 #mailbox_transport = cyrus
 mailbox_transport = cyrus

 #fallback_transport = lmtp:unix:/file/name
 #fallback_transport = cyrus
 fallback_transport = cyrus
 #fallback_transport =

''master.cf''

 cyrus     unix  -       n       n       -       -       pipe
 ##  user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${us\
er}
   user=cyrus argv=/usr/lib/cyrus-imapd/deliver -e -r ${sender} -m ${extensi\
on} ${user}


PostFixを再起動

**.sieve でメールの振り分け [#ddf11668]

.sieve でメールの振り分けを行うにはホームディレクトリに振り分けルールを書いた.sieveを置くが、これはルールを書いたサンプルをコンパイルしてバイナリで置く必要がある。

''sieve.srcのサンプル''

 # ファイル操作拡張機能の読み込み
 require "fileinto";
 
 # SpamAssassinでSPAMと判定されメールをSPAMフォルダへ移動
 if header :is "X-Spam-Flag" "YES" {
     fileinto "INBOX.SPAM";
 }

''コンパイル''~
 $ /usr/lib/cyrus-imapd/sievec sieve.src ~/.sieve

**参考 [#t96bed98]
***STLのキー作成 [#sb0b1c7b]
SSLと同じように作成
 # cd /usr/share/ssl/certs
 # ls
 Makefile  ca-bundle.crt  cyrus-imapd.pem  make-dummy-cert
 # make server.key
 umask 77 ; \
 /usr/bin/openssl genrsa -des3 1024 > server.key
 Generating RSA private key, 1024 bit long modulus
 ...........++++++
 ................++++++
 e is 65537 (0x10001)
 Enter pass phrase: *******
 Verifying - Enter pass phrase: ********
 # openssl rsa -in server.key -out server.key
 Enter pass phrase for server.key: ******
 writing RSA key
 # ls
 Makefile  ca-bundle.crt  cyrus-imapd.pem  make-dummy-cert  server.key
 
 # make server.csr
 umask 77 ; \
 /usr/bin/openssl req -new -key server.key -out server.csr
 You are about to be asked to enter information that will be incorporated
 into your certificate request.
 What you are about to enter is what is called a Distinguished Name or a DN.
 There are quite a few fields but you can leave some blank
 For some fields there will be a default value,
 If you enter '.', the field will be left blank.
 -----
 Country Name (2 letter code) [AU]:JP
 State or Province Name (full name) [Some-State]:Mie Pref.
 Locality Name (eg, city) []:Ise
 Organization Name (eg, company) [Internet Widgits Pty Ltd]:ISM
 Organizational Unit Name (eg, section) []:ISM
 Common Name (eg, YOUR name) []:ISM
 Email Address []:okada@localhost
 
 Please enter the following 'extra' attributes 
 to be sent with your certificate request
 A challenge password []:  <===Enter
 An optional company name []:  <===Enter
 # openssl x509 -in server.csr -out server.pem -req -signkey server.key -days 365
 Signature ok
 subject=/C=JP/ST=Mie Pref./L=Ise/O=ISM/OU=ISM/CN=ISM/emailAddress=okada@localhost
 Getting Private key
 # ls
 Makefile       cyrus-imapd.pem  server.csr  server.pem
 ca-bundle.crt  make-dummy-cert  server.key

***参考ページ [#i1f9ad90]

[[cyrus-imapを使ってみよう:http://tsuttayo.sytes.net/postfix/cyrus/#install]]

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS