開始行:
#html{{
<h1 style="color: red; background-color: #FFFFCC; padding...
Dovecot(ダブコット)
</h1>
<div class="alert alert-warning" role="alert">
UNIX系のOS上で動作するオープンソースのメール配送エージェ...
POP3やIMAP4に対応しています。
</div>
}}
//----------------------------------------
#contents
//----------------------------------------
//----------------------------------------
// 用語の定義
* Dovecot(ダブコット)とは? [#definition]
-Dovecot - Google 検索
https://www.google.com/search?q=Dovecot
- Dovecot - Wikipedia
https://ja.wikipedia.org/wiki/Dovecot
>Dovecot(ダヴコット、[ˈdʌvkɒt])とは、Unix系のOS上で動作...
** 公式サイト [#p74d3110]
- Dovecot | The Secure IMAP server
https://www.dovecot.org/
//----------------------------------------
* インストール [#install]
Ubuntu 24.04 に Dovecot をインストールし、基本的なメール...
** 参考記事 [#reference]
-【初心者向け】EC2を利用したメールサーバーの構築( Postfix...
https://blog.denet.co.jp/ec2-postfix-dovecot-mail-server-...
-メールサーバの用語集 - DENET 技術ブログ
https://blog.denet.co.jp/mailserverwords/
//----------------------------------------
** 1. 前提条件 [#h18be4ba]
- Ubuntu 24.04 LTS が稼働中
- mail.mydomain.net というホスト名(FQDN)で公開されている
- root または sudo 権限あり
- Postfix 等のMTAと連携する前提
//----------------------------------------
** 2. Dovecot のインストール [#n5c24ac8]
sudo apt update
sudo apt install dovecot-core dovecot-imapd dovecot-pop3d
出力例
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
libexttextcat-2.0-0 libexttextcat-data
Suggested packages:
dovecot-gssapi dovecot-ldap dovecot-lmtpd dovecot-mana...
dovecot-pgsql dovecot-sieve dovecot-solr dovecot-sqlit...
The following NEW packages will be installed:
dovecot-core dovecot-imapd dovecot-pop3d libexttextcat...
0 upgraded, 5 newly installed, 0 to remove and 1 not upg...
Need to get 3,788 kB of archives.
After this operation, 12.1 MB of additional disk space w...
Do you want to continue? [Y/n] Y ← Yを入力
//----------------------------------------
** 3. ホスト名の確認・設定 [#a64d3b6d]
hostnamectl set-hostname mail.mydomain.net
出力例
==== AUTHENTICATING FOR org.freedesktop.hostname1.set-st...
Authentication is required to set the statically configu...
Authenticating as: ,,, (USERNAME)
Password: (←作業用ユーザーのパスワードを入力)
==== AUTHENTICATION COMPLETE ====
または
''/etc/hostname'' に直接 ''mail.mydomain.net'' と記載。
sudo nano /etc/hostname
*** 確認: [#m1a8e50e]
hostname -f
出力例
mail.mydomain.net
//----------------------------------------
** 4. メールボックスのディレクトリを作成(Maildir 形式を...
*** Maildir 形式のユーザー用メールボックスを作成: [#wc91...
sudo mkdir -p /etc/skel/Maildir
sudo maildirmake.dovecot /etc/skel/Maildir
sudo maildirmake.dovecot /etc/skel/Maildir/.Drafts
sudo maildirmake.dovecot /etc/skel/Maildir/.Sent
sudo maildirmake.dovecot /etc/skel/Maildir/.Trash
*** すでにユーザーがいる場合は、そのホームディレクトリに...
sudo maildirmake.dovecot /home/USERNAME/Maildir
sudo chown -R USERNAME:USERNAME /home/USERNAME/Maildir
//----------------------------------------
** 5. Dovecot の設定ファイル編集 [#q1754b2c]
設定ファイルは ''/etc/dovecot/'' 以下にあります。
drwxr-xr-x 2 root root 4096 Mar 21 22:50 conf.d
-rw-r--r-- 1 root root 4343 Aug 27 2024 dovecot.conf
-rw-r----- 1 root dovecot 1507 Sep 14 2023 dovecot-dict...
-rw-r----- 1 root dovecot 522 Sep 14 2023 dovecot-dict...
-rw-r----- 1 root dovecot 5824 Sep 14 2023 dovecot-sql....
drwx------ 2 root root 4096 Mar 21 22:50 private
*** 「/etc/dovecot/conf.d」の中身 [#b9637d4f]
ls -la /etc/dovecot/conf.d
出力例
drwxr-xr-x 2 root root 4096 Mar 21 22:50 .
drwxr-xr-x 4 root root 4096 Mar 21 23:14 ..
-rw-r--r-- 1 root root 5248 Sep 14 2023 10-auth.conf
-rw-r--r-- 1 root root 1781 Sep 14 2023 10-director.conf
-rw-r--r-- 1 root root 3757 Sep 14 2023 10-logging.conf
-rw-r--r-- 1 root root 18068 Aug 27 2024 10-mail.conf
-rw-r--r-- 1 root root 3619 Sep 14 2023 10-master.conf
-rw-r--r-- 1 root root 3482 Aug 27 2024 10-ssl.conf
-rw-r--r-- 1 root root 291 Aug 27 2024 10-tcpwrapper....
-rw-r--r-- 1 root root 1657 Sep 14 2023 15-lda.conf
-rw-r--r-- 1 root root 3111 Sep 14 2023 15-mailboxes.c...
-rw-r--r-- 1 root root 4520 Sep 14 2023 20-imap.conf
-rw-r--r-- 1 root root 4066 Sep 14 2023 20-pop3.conf
-rw-r--r-- 1 root root 676 Sep 14 2023 90-acl.conf
-rw-r--r-- 1 root root 292 Sep 14 2023 90-plugin.conf
-rw-r--r-- 1 root root 2596 Sep 14 2023 90-quota.conf
-rw-r--r-- 1 root root 499 Sep 14 2023 auth-checkpass...
-rw-r--r-- 1 root root 489 Sep 14 2023 auth-deny.conf...
-rw-r--r-- 1 root root 343 Sep 14 2023 auth-dict.conf...
-rw-r--r-- 1 root root 561 Sep 14 2023 auth-master.co...
-rw-r--r-- 1 root root 515 Sep 14 2023 auth-passwdfil...
-rw-r--r-- 1 root root 788 Sep 14 2023 auth-sql.conf....
-rw-r--r-- 1 root root 611 Sep 14 2023 auth-static.co...
-rw-r--r-- 1 root root 2182 Sep 14 2023 auth-system.co...
いろいろな設定ファイルがあるんですね。
*** 5.1 メイン設定ファイル ''/etc/dovecot/dovecot.conf'' ...
sudo nano /etc/dovecot/dovecot.conf
↓
!include_try /usr/share/dovecot/protocols.d/*.protocol
dict {
}
!include conf.d/*.conf
デフォルトでこの構成になっているはずです。
---
*** 5.2 ''10-mail.conf'' を編集 [#odbfcd71]
10-mail.conf は、Dovecot の設定ファイルの1つで、主に''メ...
設定ファイルを編集する前にバックアップ(コピー)を取って...
sudo cp /etc/dovecot/conf.d/10-mail.conf /etc/dovecot/co...
- 拡張子が「.bak」のファイルはDovecotから、設定ファイルと...
- 拡張子が「.conf」のファイルがDovecotから、設定ファイル...
Dovecotの設定ファイルは、通常 /etc/dovecot/dovecot.conf ...
include conf.d/*.conf
この指定は、conf.d ディレクトリ内の「.conf」で終わるファ...
10-mail.confを編集して、メールのデータをMaildir形式にしま...
sudo nano /etc/dovecot/conf.d/10-mail.conf
↓
##
## Mailbox locations and namespaces
##
# Location for users' mailboxes. The default is empty, w...
# tries to find the mailboxes automatically. This won't ...
# doesn't yet have any mail, so you should explicitly te...
# location.
#
# If you're using mbox, giving a path to the INBOX file ...
# isn't enough. You'll also need to tell Dovecot where t...
# kept. This is called the "root mail directory", and it...
# path given in the mail_location setting.
#
# There are a few special variables you can use, eg.:
#
# %u - username
# %n - user part in user@domain, same as %u if there's...
# %d - domain part in user@domain, empty if there's no...
# %h - home directory
#
# See doc/wiki/Variables.txt for full list. Some examples:
#
# mail_location = maildir:~/Maildir
# mail_location = mbox:~/mail:INBOX=/var/mail/%u
# mail_location = mbox:/var/mail/%d/%1n/%n:INDEX=/var/...
#
# <doc/wiki/MailLocation.txt>
#
mail_location = mbox:~/mail:INBOX=/var/mail/%u
この行を以下ように変更します。(コメントアウトして追加し...
mail_location = maildir:~/Maildir
---
*** 5.3 ''10-auth.conf'' を編集 [#id47fdbd]
10-auth.conf は、Dovecot の認証に関する設定ファイルです。
Dovecot はメールの受信時にユーザー認証(ログイン)を行う...
設定ファイルを編集する前にバックアップ(コピー)を取って...
sudo cp /etc/dovecot/conf.d/10-auth.conf /etc/dovecot/co...
sudo nano /etc/dovecot/conf.d/10-auth.conf
次の行を確認・変更(パスワードはシステムアカウントと連動...
disable_plaintext_auth = no
auth_mechanisms = plain login
!include auth-system.conf.ext
---
*** 5.4 ''10-ssl.conf'' を編集 [#e7dbe84d]
sudo nano /etc/dovecot/conf.d/10-ssl.conf
Let’s Encrypt や自己署名証明書を使って SSL/TLS を有効にし...
ssl = yes
ssl_cert = </etc/letsencrypt/live/mail.mydomain.net/full...
ssl_key = </etc/letsencrypt/live/mail.mydomain.net/privk...
証明書が未取得の場合、後から設定可能です(仮に ''ssl = no...
---
** 6. Dovecot サービスの起動と有効化 [#g8aea3b8]
sudo systemctl restart dovecot
sudo systemctl enable dovecot
---
** 7. 動作確認 [#z8df7d0e]
IMAP(ポート143, 993)、POP3(ポート110, 995)が開いてい...
sudo ss -tnlp | grep dovecot
---
** 8. ログファイルの確認 [#h7233da4]
問題がある場合はログをチェック:
sudo journalctl -u dovecot
sudo tail -f /var/log/mail.log
---
** 9. ファイアウォールの設定(UFW を使っている場合) [#o8...
sudo ufw allow 143,993/tcp # IMAP
sudo ufw allow 110,995/tcp # POP3
---
** ✅ 補足 [#p53b363d]
- SMTP(メール送信)は Postfix など別途必要です。
- Let’s Encrypt を使った SSL 化は ''certbot'' により可能...
- Dovecot は仮想ユーザー方式も可能ですが、ここではシステ...
---
//----------------------------------------
// *Amazon [#amazon]
#html{{
}}
//----------------------------------------
* 関連 [#r4157be7]
//----------------------------------------
-[[メールサーバー]]
-[[Postfix]]
終了行:
#html{{
<h1 style="color: red; background-color: #FFFFCC; padding...
Dovecot(ダブコット)
</h1>
<div class="alert alert-warning" role="alert">
UNIX系のOS上で動作するオープンソースのメール配送エージェ...
POP3やIMAP4に対応しています。
</div>
}}
//----------------------------------------
#contents
//----------------------------------------
//----------------------------------------
// 用語の定義
* Dovecot(ダブコット)とは? [#definition]
-Dovecot - Google 検索
https://www.google.com/search?q=Dovecot
- Dovecot - Wikipedia
https://ja.wikipedia.org/wiki/Dovecot
>Dovecot(ダヴコット、[ˈdʌvkɒt])とは、Unix系のOS上で動作...
** 公式サイト [#p74d3110]
- Dovecot | The Secure IMAP server
https://www.dovecot.org/
//----------------------------------------
* インストール [#install]
Ubuntu 24.04 に Dovecot をインストールし、基本的なメール...
** 参考記事 [#reference]
-【初心者向け】EC2を利用したメールサーバーの構築( Postfix...
https://blog.denet.co.jp/ec2-postfix-dovecot-mail-server-...
-メールサーバの用語集 - DENET 技術ブログ
https://blog.denet.co.jp/mailserverwords/
//----------------------------------------
** 1. 前提条件 [#h18be4ba]
- Ubuntu 24.04 LTS が稼働中
- mail.mydomain.net というホスト名(FQDN)で公開されている
- root または sudo 権限あり
- Postfix 等のMTAと連携する前提
//----------------------------------------
** 2. Dovecot のインストール [#n5c24ac8]
sudo apt update
sudo apt install dovecot-core dovecot-imapd dovecot-pop3d
出力例
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
libexttextcat-2.0-0 libexttextcat-data
Suggested packages:
dovecot-gssapi dovecot-ldap dovecot-lmtpd dovecot-mana...
dovecot-pgsql dovecot-sieve dovecot-solr dovecot-sqlit...
The following NEW packages will be installed:
dovecot-core dovecot-imapd dovecot-pop3d libexttextcat...
0 upgraded, 5 newly installed, 0 to remove and 1 not upg...
Need to get 3,788 kB of archives.
After this operation, 12.1 MB of additional disk space w...
Do you want to continue? [Y/n] Y ← Yを入力
//----------------------------------------
** 3. ホスト名の確認・設定 [#a64d3b6d]
hostnamectl set-hostname mail.mydomain.net
出力例
==== AUTHENTICATING FOR org.freedesktop.hostname1.set-st...
Authentication is required to set the statically configu...
Authenticating as: ,,, (USERNAME)
Password: (←作業用ユーザーのパスワードを入力)
==== AUTHENTICATION COMPLETE ====
または
''/etc/hostname'' に直接 ''mail.mydomain.net'' と記載。
sudo nano /etc/hostname
*** 確認: [#m1a8e50e]
hostname -f
出力例
mail.mydomain.net
//----------------------------------------
** 4. メールボックスのディレクトリを作成(Maildir 形式を...
*** Maildir 形式のユーザー用メールボックスを作成: [#wc91...
sudo mkdir -p /etc/skel/Maildir
sudo maildirmake.dovecot /etc/skel/Maildir
sudo maildirmake.dovecot /etc/skel/Maildir/.Drafts
sudo maildirmake.dovecot /etc/skel/Maildir/.Sent
sudo maildirmake.dovecot /etc/skel/Maildir/.Trash
*** すでにユーザーがいる場合は、そのホームディレクトリに...
sudo maildirmake.dovecot /home/USERNAME/Maildir
sudo chown -R USERNAME:USERNAME /home/USERNAME/Maildir
//----------------------------------------
** 5. Dovecot の設定ファイル編集 [#q1754b2c]
設定ファイルは ''/etc/dovecot/'' 以下にあります。
drwxr-xr-x 2 root root 4096 Mar 21 22:50 conf.d
-rw-r--r-- 1 root root 4343 Aug 27 2024 dovecot.conf
-rw-r----- 1 root dovecot 1507 Sep 14 2023 dovecot-dict...
-rw-r----- 1 root dovecot 522 Sep 14 2023 dovecot-dict...
-rw-r----- 1 root dovecot 5824 Sep 14 2023 dovecot-sql....
drwx------ 2 root root 4096 Mar 21 22:50 private
*** 「/etc/dovecot/conf.d」の中身 [#b9637d4f]
ls -la /etc/dovecot/conf.d
出力例
drwxr-xr-x 2 root root 4096 Mar 21 22:50 .
drwxr-xr-x 4 root root 4096 Mar 21 23:14 ..
-rw-r--r-- 1 root root 5248 Sep 14 2023 10-auth.conf
-rw-r--r-- 1 root root 1781 Sep 14 2023 10-director.conf
-rw-r--r-- 1 root root 3757 Sep 14 2023 10-logging.conf
-rw-r--r-- 1 root root 18068 Aug 27 2024 10-mail.conf
-rw-r--r-- 1 root root 3619 Sep 14 2023 10-master.conf
-rw-r--r-- 1 root root 3482 Aug 27 2024 10-ssl.conf
-rw-r--r-- 1 root root 291 Aug 27 2024 10-tcpwrapper....
-rw-r--r-- 1 root root 1657 Sep 14 2023 15-lda.conf
-rw-r--r-- 1 root root 3111 Sep 14 2023 15-mailboxes.c...
-rw-r--r-- 1 root root 4520 Sep 14 2023 20-imap.conf
-rw-r--r-- 1 root root 4066 Sep 14 2023 20-pop3.conf
-rw-r--r-- 1 root root 676 Sep 14 2023 90-acl.conf
-rw-r--r-- 1 root root 292 Sep 14 2023 90-plugin.conf
-rw-r--r-- 1 root root 2596 Sep 14 2023 90-quota.conf
-rw-r--r-- 1 root root 499 Sep 14 2023 auth-checkpass...
-rw-r--r-- 1 root root 489 Sep 14 2023 auth-deny.conf...
-rw-r--r-- 1 root root 343 Sep 14 2023 auth-dict.conf...
-rw-r--r-- 1 root root 561 Sep 14 2023 auth-master.co...
-rw-r--r-- 1 root root 515 Sep 14 2023 auth-passwdfil...
-rw-r--r-- 1 root root 788 Sep 14 2023 auth-sql.conf....
-rw-r--r-- 1 root root 611 Sep 14 2023 auth-static.co...
-rw-r--r-- 1 root root 2182 Sep 14 2023 auth-system.co...
いろいろな設定ファイルがあるんですね。
*** 5.1 メイン設定ファイル ''/etc/dovecot/dovecot.conf'' ...
sudo nano /etc/dovecot/dovecot.conf
↓
!include_try /usr/share/dovecot/protocols.d/*.protocol
dict {
}
!include conf.d/*.conf
デフォルトでこの構成になっているはずです。
---
*** 5.2 ''10-mail.conf'' を編集 [#odbfcd71]
10-mail.conf は、Dovecot の設定ファイルの1つで、主に''メ...
設定ファイルを編集する前にバックアップ(コピー)を取って...
sudo cp /etc/dovecot/conf.d/10-mail.conf /etc/dovecot/co...
- 拡張子が「.bak」のファイルはDovecotから、設定ファイルと...
- 拡張子が「.conf」のファイルがDovecotから、設定ファイル...
Dovecotの設定ファイルは、通常 /etc/dovecot/dovecot.conf ...
include conf.d/*.conf
この指定は、conf.d ディレクトリ内の「.conf」で終わるファ...
10-mail.confを編集して、メールのデータをMaildir形式にしま...
sudo nano /etc/dovecot/conf.d/10-mail.conf
↓
##
## Mailbox locations and namespaces
##
# Location for users' mailboxes. The default is empty, w...
# tries to find the mailboxes automatically. This won't ...
# doesn't yet have any mail, so you should explicitly te...
# location.
#
# If you're using mbox, giving a path to the INBOX file ...
# isn't enough. You'll also need to tell Dovecot where t...
# kept. This is called the "root mail directory", and it...
# path given in the mail_location setting.
#
# There are a few special variables you can use, eg.:
#
# %u - username
# %n - user part in user@domain, same as %u if there's...
# %d - domain part in user@domain, empty if there's no...
# %h - home directory
#
# See doc/wiki/Variables.txt for full list. Some examples:
#
# mail_location = maildir:~/Maildir
# mail_location = mbox:~/mail:INBOX=/var/mail/%u
# mail_location = mbox:/var/mail/%d/%1n/%n:INDEX=/var/...
#
# <doc/wiki/MailLocation.txt>
#
mail_location = mbox:~/mail:INBOX=/var/mail/%u
この行を以下ように変更します。(コメントアウトして追加し...
mail_location = maildir:~/Maildir
---
*** 5.3 ''10-auth.conf'' を編集 [#id47fdbd]
10-auth.conf は、Dovecot の認証に関する設定ファイルです。
Dovecot はメールの受信時にユーザー認証(ログイン)を行う...
設定ファイルを編集する前にバックアップ(コピー)を取って...
sudo cp /etc/dovecot/conf.d/10-auth.conf /etc/dovecot/co...
sudo nano /etc/dovecot/conf.d/10-auth.conf
次の行を確認・変更(パスワードはシステムアカウントと連動...
disable_plaintext_auth = no
auth_mechanisms = plain login
!include auth-system.conf.ext
---
*** 5.4 ''10-ssl.conf'' を編集 [#e7dbe84d]
sudo nano /etc/dovecot/conf.d/10-ssl.conf
Let’s Encrypt や自己署名証明書を使って SSL/TLS を有効にし...
ssl = yes
ssl_cert = </etc/letsencrypt/live/mail.mydomain.net/full...
ssl_key = </etc/letsencrypt/live/mail.mydomain.net/privk...
証明書が未取得の場合、後から設定可能です(仮に ''ssl = no...
---
** 6. Dovecot サービスの起動と有効化 [#g8aea3b8]
sudo systemctl restart dovecot
sudo systemctl enable dovecot
---
** 7. 動作確認 [#z8df7d0e]
IMAP(ポート143, 993)、POP3(ポート110, 995)が開いてい...
sudo ss -tnlp | grep dovecot
---
** 8. ログファイルの確認 [#h7233da4]
問題がある場合はログをチェック:
sudo journalctl -u dovecot
sudo tail -f /var/log/mail.log
---
** 9. ファイアウォールの設定(UFW を使っている場合) [#o8...
sudo ufw allow 143,993/tcp # IMAP
sudo ufw allow 110,995/tcp # POP3
---
** ✅ 補足 [#p53b363d]
- SMTP(メール送信)は Postfix など別途必要です。
- Let’s Encrypt を使った SSL 化は ''certbot'' により可能...
- Dovecot は仮想ユーザー方式も可能ですが、ここではシステ...
---
//----------------------------------------
// *Amazon [#amazon]
#html{{
}}
//----------------------------------------
* 関連 [#r4157be7]
//----------------------------------------
-[[メールサーバー]]
-[[Postfix]]
ページ名: