1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

RockyLinux9.6 PostfixAdmin構築メモ(Dovecot設定)

1
Last updated at Posted at 2025-08-27

概要

Dovecotの設定(必要最低限)

環境

RockyLinux9.6(さくらのクラウド)
PostfixAdmin(3.3.15) - Sqlite

参考URL

https://www.gin-iro.work/mizuito/tec/centos/postfixadmin_postfix_dovecot_sqlite.htm
https://qiita.com/shadowhat/items/c194d2b6e589fc937106
https://www.rouge.gr.jp/~fuku/tips/postfixadmin/

事前作業

作業概要

サンプル設定 ここで使うドメイン一覧(仮)

URL or ホスト名
メールサーバのホスト名 admin.xxx.com
postfixadminの管理画面 https://admin.xxx.com/
postfixadminへ設定するドメイン① xxx.com
postfixadminへ設定するドメイン② app.xxx.com
postfixadminへ設定するドメイン③ blog.xxx.com
項目 内容
postfix 3.5.25
dovecot 2.3.16
uid vmail(989)
gid mail(12)
mail_location /var/vmail/(ドメイン名)/(ユーザ名)
  • POP3は無効化
  • IMAPSのみ(IMAPは無効)
  • TLS必須

Dovecot設定

Dovecotにて定義されている変数

%d domain
%u full username
%n user part (%u with no domain)

10-auth.conf

cp -p /etc/dovecot/conf.d/10-auth.conf /etc/dovecot/conf.d/10-auth.conf_org
vi /etc/dovecot/conf.d/10-auth.conf
以下を書き換え
---
#disable_plaintext_auth = yes
↓
disable_plaintext_auth = yes

!include auth-system.conf.ext
↓
#!include auth-system.conf.ext
(Dovecotのユーザは、すべてPostfixadminで管理するためコメントアウト。)

#!include auth-sql.conf.ext
↓
!include auth-sql.conf.ext
(SQLでユーザ認証をするようにする。)
---

10-mail.conf

cp -p /etc/dovecot/conf.d/10-mail.conf /etc/dovecot/conf.d/10-mail.conf_org
vi /etc/dovecot/conf.d/10-mail.conf
以下を書き換え
---
#mail_location = 
↓
mail_location = maildir:/var/vmail/%d/%n

first_valid_uid = 1000
#last_valid_uid = 0
↓
first_valid_uid = 989
last_valid_uid = 989
(vmailユーザのuidを指定)

#first_valid_gid = 1
#last_valid_gid = 0
↓
first_valid_gid = 12
last_valid_gid = 12
(vmailユーザのgidを指定)

---

10-master.conf

cp -p /etc/dovecot/conf.d/10-master.conf /etc/dovecot/conf.d/10-master.conf_org
vi /etc/dovecot/conf.d/10-master.conf
以下を書き換え
(port = 0に設定すると、無効化出来る。)
---
service imap-login {
  inet_listener imap {
    #port = 143
  }
  inet_listener imaps {
    #port = 993
    #ssl = yes
  }
↓
service imap-login {
  inet_listener imap {
    port = 0
  }
  inet_listener imaps {
    port = 993
    ssl = yes
  }
  
service pop3-login {
  inet_listener pop3 {
    #port = 110
  }
  inet_listener pop3s {
    #port = 995
    #ssl = yes
  }
}
↓
service pop3-login {
  inet_listener pop3 {
    port = 0
  }
  inet_listener pop3s {
    port = 0
    #ssl = yes
  }
}

  # Postfix smtp-auth
  #unix_listener /var/spool/postfix/private/auth {
  #  mode = 0666
  #}
↓
  # Postfix smtp-auth
  unix_listener /var/spool/postfix/private/auth {
    mode = 0666
    user = postfix
    group = postfix
  }
---

10-ssl.conf

cp -p /etc/dovecot/conf.d/10-ssl.conf /etc/dovecot/conf.d/10-ssl.conf_org
vi /etc/dovecot/conf.d/10-ssl.conf
以下を書き換え
("local_name (ドメイン名)"にて、ドメイン用のSSL証明書を定義する。)
---
ssl_cert = </etc/pki/dovecot/certs/dovecot.pem
ssl_key = </etc/pki/dovecot/private/dovecot.pem
↓
ssl_cert = </etc/pki/dovecot/certs/dovecot.pem
ssl_key = </etc/pki/dovecot/private/dovecot.pem
local_name xxx.com {
  ssl_cert = </etc/letsencrypt/live/xxx.com/fullchain.pem
  ssl_key = </etc/letsencrypt/live/xxx.com/privkey.pem
}
local_name app.xxx.com {
  ssl_cert = </etc/letsencrypt/live/app.xxx.com/fullchain.pem
  ssl_key = </etc/letsencrypt/live/app.xxx.com/privkey.pem
}
local_name blog.xxx.com {
  ssl_cert = </etc/letsencrypt/live/blog.xxx.com/fullchain.pem
  ssl_key = </etc/letsencrypt/live/blog.xxx.com/privkey.pem
}
---

15-lda.conf

(自動でメールディレクトリを作成する)

cp -p /etc/dovecot/conf.d/15-lda.conf /etc/dovecot/conf.d/15-lda.conf_org
vi /etc/dovecot/conf.d/15-lda.conf
以下を書き換え
---
#lda_mailbox_autocreate = no
↓
lda_mailbox_autocreate = yes
---

15-mailboxes.conf

IMAP メールボックスへ関連ディレクトリを自動作成&自動購読する。
(この設定は無理に変更する必要ない。ここは私の好みです・・・)
以下参照
https://docs.redhat.com/ja/documentation/red_hat_enterprise_linux/9/html/deploying_mail_servers/automatically-subscribing-users-to-imap-mailboxesconfiguring-and-maintaining-a-dovecot-imap-and-pop3-server

cp -p /etc/dovecot/conf.d/15-mailboxes.conf /etc/dovecot/conf.d/15-mailboxes.conf_org
vi /etc/dovecot/conf.d/15-mailboxes.conf
以下を書き換え
---
# NOTE: Assumes "namespace inbox" has been defined in 10-mail.conf.
namespace inbox {
  # These mailboxes are widely used and could perhaps be created automatically:
  mailbox Drafts {
    special_use = \Drafts
  }
  mailbox Junk {
    special_use = \Junk
  }
  mailbox Trash {
    special_use = \Trash
  }

  # For \Sent mailboxes there are two widely used names. We'll mark both of
  # them as \Sent. User typically deletes one of them if duplicates are created.
  mailbox Sent {
    special_use = \Sent
  }
↓
# NOTE: Assumes "namespace inbox" has been defined in 10-mail.conf.
namespace inbox {
  # These mailboxes are widely used and could perhaps be created automatically:
  mailbox Drafts {
    special_use = \Drafts
    auto = subscribe
  }
  mailbox Junk {
    special_use = \Junk
    auto = subscribe
  }
  mailbox Trash {
    special_use = \Trash
    auto = subscribe
  }

  # For \Sent mailboxes there are two widely used names. We'll mark both of
  # them as \Sent. User typically deletes one of them if duplicates are created.
  mailbox Sent {
    special_use = \Sent
    auto = subscribe
  }
---

auth-sql.conf.ext

cp -p /etc/dovecot/conf.d/auth-sql.conf.ext /etc/dovecot/conf.d/auth-sql.conf.ext_org
vi /etc/dovecot/conf.d/auth-sql.conf.ext
以下を書き換え
---
passdb {
  driver = sql

  # Path for SQL configuration file, see example-config/dovecot-sql.conf.ext
  args = /etc/dovecot/dovecot-sql.conf.ext
}
↓
passdb {
  driver = sql

  # Path for SQL configuration file, see example-config/dovecot-sql.conf.ext
  args = /etc/dovecot/dovecot-sqlite.conf
}

userdb {
  driver = sql
  args = /etc/dovecot/dovecot-sql.conf.ext
}
↓
userdb {
  driver = sql
  args = /etc/dovecot/dovecot-sqlite.conf
}
---

SQL関連設定

https://github.com/postfixadmin/postfixadmin/blob/master/DOCUMENTS/DOVECOT.txt
を参考にしました。

vi /etc/dovecot/dovecot-sqlite.conf
---
driver = sqlite
connect = /srv/postfixadmin/database/postfixadmin.db
password_query = SELECT username AS user, password FROM mailbox WHERE username = '%n' AND active='1'
user_query = SELECT '/var/vmail/%d/%n' AS home, 989 AS uid, 12 AS gid, '*:bytes=' || quota AS quota_rule FROM mailbox WHERE username = '%n' AND active='1'
iterate_query = SELECT username as user FROM mailbox WHERE active = '1'
---

Dovecot設定反映

systemctl reload dovecot

次回は、バリュードメインの設定例

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?