Opensourcetechブログ

OpensourcetechによるNGINX/Kubernetes/Zabbix/Neo4j/Linuxなどオープンソース技術に関するブログです。

メールサーバ構築 on Ubuntu 22.04 LTS

LinuCエヴァンジェリスト・Open Source Summit Japanボランティアリーダー鯨井貴博@opensourcetechです。


はじめに
今回は、Ubuntu Server 22.04 LTS(VM)にメールサーバを構築します。

ソフトウェアインストール
postfix(SMTP)とdovecot(POP/IMAP)をインストールします。
dovecotが、dovecot-core・dovecot-imapd・dovecot-pop3dと3つに分かれている点がRPM系と違いますね!

ubuntu@ubuntu:~$ sudo apt update
[sudo] password for ubuntu: 
Hit:1 http://jp.archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://jp.archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
Hit:3 http://jp.archive.ubuntu.com/ubuntu jammy-backports InRelease
Get:4 http://jp.archive.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:5 http://jp.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [1421 kB]
Get:6 http://jp.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages [1052 kB]
Get:7 http://jp.archive.ubuntu.com/ubuntu jammy-security/main amd64 Packages [1205 kB]
Get:8 http://jp.archive.ubuntu.com/ubuntu jammy-security/universe amd64 Packages [846 kB]
Fetched 4752 kB in 4s (1255 kB/s)                         
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
42 packages can be upgraded. Run 'apt list --upgradable' to see them.

ubuntu@ubuntu:~$ sudo apt install postfix 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 liblua5.3-0 ssl-cert
Suggested packages:
  dovecot-gssapi dovecot-ldap dovecot-lmtpd dovecot-lucene dovecot-managesieved dovecot-mysql dovecot-pgsql dovecot-sieve dovecot-solr dovecot-sqlite
  dovecot-submissiond ntp ufw procmail postfix-mysql postfix-pgsql postfix-ldap postfix-pcre postfix-lmdb postfix-sqlite resolvconf postfix-cdb
  mail-reader postfix-mta-sts-resolver postfix-doc
The following NEW packages will be installed:
  dovecot-core dovecot-imapd dovecot-pop3d libexttextcat-2.0-0 libexttextcat-data liblua5.3-0 postfix ssl-cert
0 upgraded, 8 newly installed, 0 to remove and 42 not upgraded.
Need to get 5148 kB of archives.
After this operation, 16.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://jp.archive.ubuntu.com/ubuntu jammy/main amd64 ssl-cert all 1.1.2 [17.4 kB]
Get:2 http://jp.archive.ubuntu.com/ubuntu jammy/main amd64 libexttextcat-data all 3.4.5-1build2 [179 kB]
Get:3 http://jp.archive.ubuntu.com/ubuntu jammy/main amd64 libexttextcat-2.0-0 amd64 3.4.5-1build2 [13.7 kB]
Get:4 http://jp.archive.ubuntu.com/ubuntu jammy/main amd64 liblua5.3-0 amd64 5.3.6-1build1 [140 kB]
Get:5 http://jp.archive.ubuntu.com/ubuntu jammy-updates/main amd64 dovecot-core amd64 1:2.3.16+dfsg1-3ubuntu2.2 [3319 kB]
Get:6 http://jp.archive.ubuntu.com/ubuntu jammy-updates/main amd64 postfix amd64 3.6.4-1ubuntu1.3 [1248 kB]
Get:7 http://jp.archive.ubuntu.com/ubuntu jammy-updates/main amd64 dovecot-imapd amd64 1:2.3.16+dfsg1-3ubuntu2.2 [193 kB]
Get:8 http://jp.archive.ubuntu.com/ubuntu jammy-updates/main amd64 dovecot-pop3d amd64 1:2.3.16+dfsg1-3ubuntu2.2 [37.7 kB]
Fetched 5148 kB in 3s (1543 kB/s)         
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package ssl-cert.
(Reading database ... 66264 files and directories currently installed.)
Preparing to unpack .../0-ssl-cert_1.1.2_all.deb ...
Unpacking ssl-cert (1.1.2) ...
Selecting previously unselected package libexttextcat-data.
Preparing to unpack .../1-libexttextcat-data_3.4.5-1build2_all.deb ...
Unpacking libexttextcat-data (3.4.5-1build2) ...
Selecting previously unselected package libexttextcat-2.0-0:amd64.
Preparing to unpack .../2-libexttextcat-2.0-0_3.4.5-1build2_amd64.deb ...
Unpacking libexttextcat-2.0-0:amd64 (3.4.5-1build2) ...
Selecting previously unselected package liblua5.3-0:amd64.
Preparing to unpack .../3-liblua5.3-0_5.3.6-1build1_amd64.deb ...
Unpacking liblua5.3-0:amd64 (5.3.6-1build1) ...
Selecting previously unselected package dovecot-core.
Preparing to unpack .../4-dovecot-core_1%3a2.3.16+dfsg1-3ubuntu2.2_amd64.deb ...
Unpacking dovecot-core (1:2.3.16+dfsg1-3ubuntu2.2) ...
Selecting previously unselected package postfix.
Preparing to unpack .../5-postfix_3.6.4-1ubuntu1.3_amd64.deb ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline
Postfix Configuration
---------------------

Please select the mail server configuration type that best meets your needs.

 No configuration:
  Should be chosen to leave the current configuration unchanged.
 Internet site:
  Mail is sent and received directly using SMTP.
 Internet with smarthost:
  Mail is received directly using SMTP or by running a utility such
  as fetchmail. Outgoing mail is sent using a smarthost.
 Satellite system:
  All mail is sent to another machine, called a 'smarthost', for
  delivery.
 Local only:
  The only delivered mail is the mail for local users. There is no
  network.

  1. No configuration  2. Internet Site  3. Internet with smarthost  4. Satellite system  5. Local only
General mail configuration type: 1

Unpacking postfix (3.6.4-1ubuntu1.3) ...
Selecting previously unselected package dovecot-imapd.
Preparing to unpack .../6-dovecot-imapd_1%3a2.3.16+dfsg1-3ubuntu2.2_amd64.deb ...
Unpacking dovecot-imapd (1:2.3.16+dfsg1-3ubuntu2.2) ...
Selecting previously unselected package dovecot-pop3d.
Preparing to unpack .../7-dovecot-pop3d_1%3a2.3.16+dfsg1-3ubuntu2.2_amd64.deb ...
Unpacking dovecot-pop3d (1:2.3.16+dfsg1-3ubuntu2.2) ...
Setting up ssl-cert (1.1.2) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline
Setting up postfix (3.6.4-1ubuntu1.3) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline
Adding group `postfix' (GID 114) ...
Done.
Adding system user `postfix' (UID 109) ...
Adding new user `postfix' (UID 109) with group `postfix' ...
Not creating home directory `/var/spool/postfix'.
Creating /etc/postfix/dynamicmaps.cf
Adding group `postdrop' (GID 115) ...
Done.
/etc/aliases does not exist, creating it.

Postfix (main.cf) was not set up.  Start with
  cp /usr/share/postfix/main.cf.debian /etc/postfix/main.cf
.  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 'systemctl reload postfix'.

Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /lib/systemd/system/postfix.service.
Setting up libexttextcat-data (3.4.5-1build2) ...
Setting up liblua5.3-0:amd64 (5.3.6-1build1) ...
Setting up libexttextcat-2.0-0:amd64 (3.4.5-1build2) ...
Setting up dovecot-core (1:2.3.16+dfsg1-3ubuntu2.2) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/dovecot.conf with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/dovecot-dict-auth.conf.ext with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/dovecot-dict-sql.conf.ext with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/dovecot-sql.conf.ext with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/10-auth.conf with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/10-director.conf with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/10-logging.conf with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/10-mail.conf with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/10-master.conf with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/10-ssl.conf with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/10-tcpwrapper.conf with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/15-lda.conf with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/15-mailboxes.conf with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/90-acl.conf with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/90-plugin.conf with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/90-quota.conf with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/auth-checkpassword.conf.ext with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/auth-deny.conf.ext with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/auth-dict.conf.ext with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/auth-master.conf.ext with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/auth-passwdfile.conf.ext with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/auth-sql.conf.ext with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/auth-static.conf.ext with new version
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/auth-system.conf.ext with new version
Created symlink /etc/systemd/system/multi-user.target.wants/dovecot.service → /lib/systemd/system/dovecot.service.
dovecot.socket is a disabled or a static unit, not starting it.
Setting up dovecot-imapd (1:2.3.16+dfsg1-3ubuntu2.2) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/20-imap.conf with new version
Setting up dovecot-pop3d (1:2.3.16+dfsg1-3ubuntu2.2) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline

Creating config file /etc/dovecot/conf.d/20-pop3.conf with new version
Processing triggers for libc-bin (2.35-0ubuntu3.6) ...
Processing triggers for dovecot-core (1:2.3.16+dfsg1-3ubuntu2.2) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline
Scanning processes...                                                                                                                                     
Scanning linux images...                                                                                                                                  

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.

ubuntu@ubuntu:~$ sudo systemctl install mailutils
Unknown command verb install.
ubuntu@ubuntu:~$ sudo apt install mailutils
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  gsasl-common guile-3.0-libs libfribidi0 libgc1 libgsasl7 libidn12 libltdl7 libmailutils8
  libmysqlclient21 libntlm0 libpq5 mailutils-common mysql-common
Suggested packages:
  mailutils-mh mailutils-doc
The following NEW packages will be installed:
  gsasl-common guile-3.0-libs libfribidi0 libgc1 libgsasl7 libidn12 libltdl7 libmailutils8
  libmysqlclient21 libntlm0 libpq5 mailutils mailutils-common mysql-common
0 upgraded, 14 newly installed, 0 to remove and 42 not upgraded.
Need to get 10.4 MB of archives.
After this operation, 67.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://jp.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libfribidi0 amd64 1.0.8-2ubuntu3.1 [26.1 kB]
Get:2 http://jp.archive.ubuntu.com/ubuntu jammy/universe amd64 gsasl-common all 1.10.0-5 [59.8 kB]
Get:3 http://jp.archive.ubuntu.com/ubuntu jammy/main amd64 libgc1 amd64 1:8.0.6-1.1build1 [96.8 kB]
Get:4 http://jp.archive.ubuntu.com/ubuntu jammy/universe amd64 guile-3.0-libs amd64 3.0.7-1 [7538 kB]
Get:5 http://jp.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libidn12 amd64 1.38-4ubuntu1 [60.0 kB]
Get:6 http://jp.archive.ubuntu.com/ubuntu jammy/universe amd64 libntlm0 amd64 1.6-4 [73.7 kB]
Get:7 http://jp.archive.ubuntu.com/ubuntu jammy/universe amd64 libgsasl7 amd64 1.10.0-5 [71.1 kB]
Get:8 http://jp.archive.ubuntu.com/ubuntu jammy/main amd64 libltdl7 amd64 2.4.6-15build2 [39.6 kB]
Get:9 http://jp.archive.ubuntu.com/ubuntu jammy/universe amd64 mailutils-common all 1:3.14-1 [382 kB]
Get:10 http://jp.archive.ubuntu.com/ubuntu jammy/main amd64 mysql-common all 5.8+1.0.8 [7212 B]
Get:11 http://jp.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libmysqlclient21 amd64 8.0.36-0ubuntu0.22.04.1 [1302 kB]
Get:12 http://jp.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpq5 amd64 14.11-0ubuntu0.22.04.1 [144 kB]
Get:13 http://jp.archive.ubuntu.com/ubuntu jammy/universe amd64 libmailutils8 amd64 1:3.14-1 [519 kB]
Get:14 http://jp.archive.ubuntu.com/ubuntu jammy/universe amd64 mailutils amd64 1:3.14-1 [130 kB]
Fetched 10.4 MB in 4s (2601 kB/s)  
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libfribidi0:amd64.
(Reading database ... 67215 files and directories currently installed.)
Preparing to unpack .../00-libfribidi0_1.0.8-2ubuntu3.1_amd64.deb ...
Unpacking libfribidi0:amd64 (1.0.8-2ubuntu3.1) ...
Selecting previously unselected package gsasl-common.
Preparing to unpack .../01-gsasl-common_1.10.0-5_all.deb ...
Unpacking gsasl-common (1.10.0-5) ...
Selecting previously unselected package libgc1:amd64.
Preparing to unpack .../02-libgc1_1%3a8.0.6-1.1build1_amd64.deb ...
Unpacking libgc1:amd64 (1:8.0.6-1.1build1) ...
Selecting previously unselected package guile-3.0-libs:amd64.
Preparing to unpack .../03-guile-3.0-libs_3.0.7-1_amd64.deb ...
Unpacking guile-3.0-libs:amd64 (3.0.7-1) ...
Selecting previously unselected package libidn12:amd64.
Preparing to unpack .../04-libidn12_1.38-4ubuntu1_amd64.deb ...
Unpacking libidn12:amd64 (1.38-4ubuntu1) ...
Selecting previously unselected package libntlm0:amd64.
Preparing to unpack .../05-libntlm0_1.6-4_amd64.deb ...
Unpacking libntlm0:amd64 (1.6-4) ...
Selecting previously unselected package libgsasl7:amd64.
Preparing to unpack .../06-libgsasl7_1.10.0-5_amd64.deb ...
Unpacking libgsasl7:amd64 (1.10.0-5) ...
Selecting previously unselected package libltdl7:amd64.
Preparing to unpack .../07-libltdl7_2.4.6-15build2_amd64.deb ...
Unpacking libltdl7:amd64 (2.4.6-15build2) ...
Selecting previously unselected package mailutils-common.
Preparing to unpack .../08-mailutils-common_1%3a3.14-1_all.deb ...
Unpacking mailutils-common (1:3.14-1) ...
Selecting previously unselected package mysql-common.
Preparing to unpack .../09-mysql-common_5.8+1.0.8_all.deb ...
Unpacking mysql-common (5.8+1.0.8) ...
Selecting previously unselected package libmysqlclient21:amd64.
Preparing to unpack .../10-libmysqlclient21_8.0.36-0ubuntu0.22.04.1_amd64.deb ...
Unpacking libmysqlclient21:amd64 (8.0.36-0ubuntu0.22.04.1) ...
Selecting previously unselected package libpq5:amd64.
Preparing to unpack .../11-libpq5_14.11-0ubuntu0.22.04.1_amd64.deb ...
Unpacking libpq5:amd64 (14.11-0ubuntu0.22.04.1) ...
Selecting previously unselected package libmailutils8:amd64.
Preparing to unpack .../12-libmailutils8_1%3a3.14-1_amd64.deb ...
Unpacking libmailutils8:amd64 (1:3.14-1) ...
Selecting previously unselected package mailutils.
Preparing to unpack .../13-mailutils_1%3a3.14-1_amd64.deb ...
Unpacking mailutils (1:3.14-1) ...
Setting up mysql-common (5.8+1.0.8) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Setting up libmysqlclient21:amd64 (8.0.36-0ubuntu0.22.04.1) ...
Setting up libpq5:amd64 (14.11-0ubuntu0.22.04.1) ...
Setting up libntlm0:amd64 (1.6-4) ...
Setting up libfribidi0:amd64 (1.0.8-2ubuntu3.1) ...
Setting up libidn12:amd64 (1.38-4ubuntu1) ...
Setting up mailutils-common (1:3.14-1) ...
Setting up libgc1:amd64 (1:8.0.6-1.1build1) ...
Setting up libltdl7:amd64 (2.4.6-15build2) ...
Setting up gsasl-common (1.10.0-5) ...
Setting up guile-3.0-libs:amd64 (3.0.7-1) ...
Setting up libgsasl7:amd64 (1.10.0-5) ...
Setting up libmailutils8:amd64 (1:3.14-1) ...
Setting up mailutils (1:3.14-1) ...
update-alternatives: using /usr/bin/frm.mailutils to provide /usr/bin/frm (frm) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/frm.1.gz because associated file /usr/share/man/man1/frm.mailutils.1.gz (of link group frm) doesn't exist
update-alternatives: using /usr/bin/from.mailutils to provide /usr/bin/from (from) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/from.1.gz because associated file /usr/share/man/man1/from.mailutils.1.gz (of link group from) doesn't exist
update-alternatives: using /usr/bin/messages.mailutils to provide /usr/bin/messages (messages) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/messages.1.gz because associated file /usr/share/man/man1/messages.mailutils.1.gz (of link group messages) doesn't exist
update-alternatives: using /usr/bin/movemail.mailutils to provide /usr/bin/movemail (movemail) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/movemail.1.gz because associated file /usr/share/man/man1/movemail.mailutils.1.gz (of link group movemail) doesn't exist
update-alternatives: using /usr/bin/readmsg.mailutils to provide /usr/bin/readmsg (readmsg) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/readmsg.1.gz because associated file /usr/share/man/man1/readmsg.mailutils.1.gz (of link group readmsg) doesn't exist
update-alternatives: using /usr/bin/dotlock.mailutils to provide /usr/bin/dotlock (dotlock) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/dotlock.1.gz because associated file /usr/share/man/man1/dotlock.mailutils.1.gz (of link group dotlock) doesn't exist
update-alternatives: using /usr/bin/mail.mailutils to provide /usr/bin/mailx (mailx) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/man1/mailx.1.gz because associated file /usr/share/man/man1/mail.mailutils.1.gz (of link group mailx) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/mail.1.gz because associated file /usr/share/man/man1/mail.mailutils.1.gz (of link group mailx) doesn't exist
Processing triggers for libc-bin (2.35-0ubuntu3.6) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 78.)
debconf: falling back to frontend: Readline
Scanning processes...                                                                                
Scanning linux images...                                                                             

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.



postfixの設定

ubuntu@ubuntu:~$ sudo cp /etc/postfix/main.cf.proto /etc/postfix/main.cf

ubuntu@ubuntu:~$ sudo vi /etc/postfix/main.cf

ubuntu@ubuntu:~$ grep -v "^#" /etc/postfix/main.cf
compatibility_level = 3.6
command_directory = /usr/sbin
daemon_directory = /usr/lib/postfix/sbin
data_directory = /var/lib/postfix
myhostname = mail.opensourcetech.test
mydomain = opensourcetech.test
inet_interfaces = localhost, 192.168.1.114
mydestination = $mydomain
unknown_local_recipient_reject_code = 550
mynetworks = 127.0.0.0/8, 192.168.1.0/24
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
debugger_command =
         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
         ddd $daemon_directory/$process_name $process_id & sleep 5
inet_protocols = ipv4
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination



postfixの起動

ubuntu@ubuntu:~$ sudo systemctl start postfix

ubuntu@ubuntu:~$ sudo systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
     Loaded: loaded (/lib/systemd/system/postfix.service; enabled; vendor preset: enabled)
     Active: active (exited) since Mon 2024-03-04 09:27:32 UTC; 1s ago
       Docs: man:postfix(1)
    Process: 1319 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
   Main PID: 1319 (code=exited, status=0/SUCCESS)
        CPU: 10ms

Mar 04 09:27:32 ubuntu systemd[1]: Starting Postfix Mail Transport Agent...
Mar 04 09:27:32 ubuntu systemd[1]: Finished Postfix Mail Transport Agent.



dovecotの設定

ubuntu@ubuntu:~$ ls /etc/dovecot
conf.d                      dovecot-dict-sql.conf.ext  dovecot.conf
dovecot-dict-auth.conf.ext  dovecot-sql.conf.ext       private

ubuntu@ubuntu:~$ ls /etc/dovecot/conf.d
10-auth.conf      10-tcpwrapper.conf  90-plugin.conf               auth-passwdfile.conf.ext
10-director.conf  15-lda.conf         90-quota.conf                auth-sql.conf.ext
10-logging.conf   15-mailboxes.conf   auth-checkpassword.conf.ext  auth-static.conf.ext
10-mail.conf      20-imap.conf        auth-deny.conf.ext           auth-system.conf.ext
10-master.conf    20-pop3.conf        auth-dict.conf.ext
10-ssl.conf       90-acl.conf         auth-master.conf.ext

各種設定の変更。

ubuntu@ubuntu:~$ sudo vi /etc/dovecot/dovecot.conf 

ubuntu@ubuntu:~$ grep -v ^# /etc/dovecot/dovecot.conf 
# Enable installed protocols
!include_try /usr/share/dovecot/protocols.d/*.protocol
listen = *, ::

ubuntu@ubuntu:~$ ll /usr/share/dovecot/protocols.d/
total 16
drwxr-xr-x 2 root root 4096 Mar  4 07:25 ./
drwxr-xr-x 5 root root 4096 Mar  4 07:24 ../
-rw-r--r-- 1 root root   28 Mar  4 07:25 imapd.protocol
-rw-r--r-- 1 root root   28 Mar  4 07:25 pop3d.protocol

ubuntu@ubuntu:~$ cat /usr/share/dovecot/protocols.d/pop3d.protocol 
protocols = $protocols pop3

ubuntu@ubuntu:~$ cat /usr/share/dovecot/protocols.d/imapd.protocol 
protocols = $protocols imap

ubuntu@ubuntu:~$ sudo vi /etc/dovecot/conf.d/10-mail.conf 

ubuntu@ubuntu:~$ grep -v ^# /etc/dovecot/conf.d/10-mail.conf 
mail_location = mbox:~/mail:INBOX=/var/mail/%u
mail_privileged_group = mail
mail_access_groups = mail

ubuntu@ubuntu:~$ sudo vi /etc/dovecot/conf.d/10-auth.conf 

ubuntu@ubuntu:~$ grep -v ^# /etc/dovecot/conf.d/10-auth.conf 
disable_plaintext_auth = no

ubuntu@ubuntu:~$ sudo vi /etc/dovecot/conf.d/10-ssl.conf 

ubuntu@ubuntu:~$ grep -v ^# /etc/dovecot/conf.d/10-ssl.conf 
ssl = no



dovecotの起動

ubuntu@ubuntu:~$ sudo systemctl start dovecot

ubuntu@ubuntu:~$ sudo systemctl status dovecot
● dovecot.service - Dovecot IMAP/POP3 email server
     Loaded: loaded (/lib/systemd/system/dovecot.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2024-03-04 09:05:15 UTC; 1h 44min ago
       Docs: man:dovecot(1)
             https://doc.dovecot.org/
   Main PID: 601 (dovecot)
     Status: "v2.3.16 (7e2e900c1a) running"
      Tasks: 4 (limit: 2221)
     Memory: 5.3M
        CPU: 173ms
     CGroup: /system.slice/dovecot.service
             ├─601 /usr/sbin/dovecot -F
             ├─635 dovecot/anvil
             ├─636 dovecot/log
             └─637 dovecot/config



動作確認
以下の2ユーザ間でmailコマンドを使った操作すればOKです。
※その他、thunderbirdなどを使ったメーラーからの操作でもよし。

ubuntu@ubuntu:~$ cat /etc/passwd
.
.
.
省略
.
.
.
user1:x:1001:1001::/home/user1:/bin/sh
user2:x:1002:1002::/home/user2:/bin/sh

Opensourcetech by Takahiro Kujirai