YANO's digital garage

Copyright ©YANO All rights reserved. https://www.bravotouring.com/~yano/

Last-modified: 2024-04-17 (水)


[一語一絵/IT系]

さくらのVPS 3日目 / 2011-04-24 (日)

21日22日に続いてメールサーバpostfixdovecot-postfixのinstall。ちなみにpostfixがVersion 2.7.0-1で、dovecot-postfixはVersion 1:1.2.9-1ubuntu6となった。

$ apt-get install postfix dovecot-postfix
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  dovecot-common dovecot-imapd dovecot-pop3d libpq5
Suggested packages:
  procmail postfix-mysql postfix-pgsql postfix-ldap postfix-pcre sasl2-bin resolvconf postfix-cdb mail-reader
The following NEW packages will be installed:
  dovecot-common dovecot-imapd dovecot-pop3d dovecot-postfix libpq5 postfix
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 9,371kB of archives.
After this operation, 19.0MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://jp.archive.ubuntu.com/ubuntu/ lucid-updates/main libpq5 8.4.7-0ubuntu0.10.04 [86.2kB]
Get:2 http://jp.archive.ubuntu.com/ubuntu/ lucid-updates/main dovecot-common 1:1.2.9-1ubuntu6.3 [5,216kB]
Get:3 http://jp.archive.ubuntu.com/ubuntu/ lucid-updates/main dovecot-imapd 1:1.2.9-1ubuntu6.3 [1,165kB]
Get:4 http://jp.archive.ubuntu.com/ubuntu/ lucid-updates/main dovecot-pop3d 1:1.2.9-1ubuntu6.3 [1,064kB]
Get:5 http://jp.archive.ubuntu.com/ubuntu/ lucid-updates/main postfix 2.7.0-1ubuntu0.1 [1,321kB]
Get:6 http://jp.archive.ubuntu.com/ubuntu/ lucid-updates/main dovecot-postfix 1:1.2.9-1ubuntu6.3 [518kB]
Fetched 9,371kB in 5s (1,782kB/s)
Preconfiguring packages ...
Selecting previously deselected package libpq5.
(Reading database ... 43158 files and directories currently installed.)
Unpacking libpq5 (from .../libpq5_8.4.7-0ubuntu0.10.04_i386.deb) ...
Selecting previously deselected package dovecot-common.
Unpacking dovecot-common (from .../dovecot-common_1%3a1.2.9-1ubuntu6.3_i386.deb) ...
Selecting previously deselected package dovecot-imapd.
Unpacking dovecot-imapd (from .../dovecot-imapd_1%3a1.2.9-1ubuntu6.3_i386.deb) ...
Selecting previously deselected package dovecot-pop3d.
Unpacking dovecot-pop3d (from .../dovecot-pop3d_1%3a1.2.9-1ubuntu6.3_i386.deb) ...
Selecting previously deselected package postfix.
Unpacking postfix (from .../postfix_2.7.0-1ubuntu0.1_i386.deb) ...
Selecting previously deselected package dovecot-postfix.
Unpacking dovecot-postfix (from .../dovecot-postfix_1%3a1.2.9-1ubuntu6.3_all.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
Processing triggers for ufw ...
Setting up libpq5 (8.4.7-0ubuntu0.10.04) ...

Setting up dovecot-common (1:1.2.9-1ubuntu6.3) ...

Creating config file /etc/dovecot/dovecot.conf with new version

Creating config file /etc/dovecot/dovecot-ldap.conf with new version

Creating config file /etc/dovecot/dovecot-sql.conf with new version
adduser: Warning: The home directory `/usr/lib/dovecot' does not belong to the user you are currently creating.
Creating generic self-signed certificate:  /etc/ssl/certs/dovecot.pem
(replace with hand-crafted or authorized one if needed).
update-rc.d: warning: dovecot stop runlevel arguments (1) do not match LSB Default-Stop values (0 1 6)
* Starting IMAP/POP3 mail server dovecot                                                                [ OK ]

Setting up dovecot-imapd (1:1.2.9-1ubuntu6.3) ...
* Restarting IMAP/POP3 mail server dovecot
If you have trouble with authentication failures,
enable auth_debug setting. See http://wiki.dovecot.org/WhyDoesItNotWork
This message goes away after the first successful login.
                                                                                                         [ OK ]

Setting up dovecot-pop3d (1:1.2.9-1ubuntu6.3) ...
* Restarting IMAP/POP3 mail server dovecot
If you have trouble with authentication failures,
enable auth_debug setting. See http://wiki.dovecot.org/WhyDoesItNotWork
This message goes away after the first successful login.
                                                                                                         [ OK ]

Setting up postfix (2.7.0-1ubuntu0.1) ...
Adding group `postfix' (GID 114) ...
Done.
Adding system user `postfix' (UID 106) ...
Adding new user `postfix' (UID 106) with group `postfix' ...
Not creating home directory `/var/spool/postfix'.
Creating /etc/postfix/dynamicmaps.cf
Adding tcp map entry to /etc/postfix/dynamicmaps.cf
Adding group `postdrop' (GID 115) ...
Done.
setting myhostname: mail.bravotouring.com
setting alias maps
setting alias database
changing /etc/mailname to mail.bravotouring.com
setting myorigin
setting destinations: mail.bravotouring.com, localhost
setting relayhost:
setting mynetworks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
setting mailbox_size_limit: 0
setting recipient_delimiter: +
setting inet_interfaces: all
/etc/aliases does not exist, creating it.
WARNING: /etc/aliases exists, but does not have a root alias.

Postfix is now set up with a default configuration.  If you need to make
changes, edit
/etc/postfix/main.cf (and others) as needed.  To view Postfix configuration
values, see postconf(1).

After modifying main.cf, be sure to run '/etc/init.d/postfix reload'.

Running newaliases
* Stopping Postfix Mail Transport Agent postfix                                                         [ OK ]
* Starting Postfix Mail Transport Agent postfix                                                         [ OK ]

Setting up dovecot-postfix (1:1.2.9-1ubuntu6.3) ...
Configuring postfix for dovecot-postfix integration: .................... done.
* Restarting IMAP/POP3 mail server dovecot
If you have trouble with authentication failures,
enable auth_debug setting. See http://wiki.dovecot.org/WhyDoesItNotWork
This message goes away after the first successful login.
                                                                                                         [ OK ]
* Stopping Postfix Mail Transport Agent postfix                                                         [ OK ]
* Starting Postfix Mail Transport Agent postfix                                                         [ OK ]

Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

まずは、バーチャルドメイン管理ユーザー(10000:10000)の"post"を追加。

$ sudo groupadd -g 10000 post
$ sudo useradd -u 10000 -g 10000 -d /home/post -s /sbin/nologin post
$ sudo mkdir /home/post

続いて、/etc/postfix/main.cfを編集。

## Virtual Domain support
virtual_mailbox_base = /home/post
virtual_alias_maps = hash:/etc/postfix/virtual
virtual_alias_domains = $virtual_alias_maps
virtual_mailbox_domains = $mydomain
virtual_mailbox_maps = hash:/etc/postfix/vmailbox
virtual_minimum_uid = 10000
virtual_uid_maps = static:10000
virtual_gid_maps = static:10000
virtual_mailbox_limit = 512000000

そして/etc/postfix/vmailboxにメールアカウントを設定。実際はbravotouring.comは自宅で使用中なので、ここではテスト用のドメインとしておく。

# bravotouring.com
yano@test.com yano/Maildir/
mail@test.com mail/Maildir/
yoko@test.com yoko/Maildir/
natsumi@test.com natsumi/Maildir/
設定終了後、
$ sudo postmap /etc/postfix/vmailbox
を忘れずに。

さらに/etc/postfix/virtualに転送用エイリアスを設定。

# bravotouring.com
webmaster@test.com yano@test.com
postmaster@test.com yano@test.com
domainadmin@test.com yano@test.com
こちらも
$ sudo postmap /etc/postfix/virtual
を忘れずに。

ここまでやって、/var/log/mail.logで外部からyano@test.com宛のメール受信を確認OK。

続いてpop対応すべく、/usr/local/etc/dovecot-passwdにpopアカウントを設定。

yano:{plain}PASSWORD
mail:{plain}PASSWORD
yoko:{plain}PASSWORD
natsumi:{plain}PASSWORD
言うまでもなく"PASSWORD"は実際のパスワードになるのだが、{plain}に続けてプレーンテキストで書けばよい。こちらは後処理不要。

あとは/etc/dovecot/auth.d/01-dovecot-postfix.authを書いてサクっと受信OKとなるはずだったのが、さにあらず。

mechanisms = plain login
socket listen {
    client {
        path = /var/spool/postfix/private/dovecot-auth
        mode = 0660
        user = postfix
        group = postfix
    }
}

passdb passwd-file {
    args = /usr/local/etc/dovecot-passwd
}

userdb static {
    args = uid=10000 gid=10000 home=/home/post/%n/Maildir
}
と書いたのに
dovecot: POP3(yano): stat(/home/post/yano/Maildir/tmp) failed: Permission denied (euid=1000(yano) egid=1000(owner) missing +x perm: /home/post/yano)
というエラーに悩まされ続けた。

2日間に渡る悪戦苦闘の結果、/etc/dovecot/dovecot.confに残るuserdbブロック

  userdb passwd {
    # [blocking=yes] - By default the lookups are done in the main dovecot-auth
    # process. This setting causes the lookups to be done in auth worker
    # proceses. Useful with remote NSS lookups that may block.
    # NOTE: Be sure to use this setting with nss_ldap or users might get
    # logged in as each others!
    #args =
  }
と競合している気がしたので、こちらをコメントアウトしてようやくPOP受信まで成功。

明日はSMTP送信だ。

【参照】
●VPS(仮想専用サーバ)のさくらインターネット http://vps.sakura.ad.jp/
●Postfixのぺーじ http://www.postfix-jp.info/
●Dovecot 翻訳プロジェクト http://www.dovecot.jp/