事前に DNS の設定を済ませておきます。今回は example.com の MX レコードを mail.example.com に設定してあります。
環境
- OS: Debian 9 (Stretch)
 - VPS: ConoHa 512 MB
 
Postfix のインストール
# apt install postfix

“Postfix Configuration” では “Internet Site” を選択します。
Postfix の設定
設定項目が多すぎてどこを変更したのかわからなくなるので、元のファイルを残しておきます。
# cp /etc/postfix/main.cf /etc/postfix/main.cf.backup # cp /etc/postfix/master.cf /etc/postfix/master.cf.backup
/etc/postfix/main.cf
...
# SASL
smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
# TLS parameters
smtpd_tls_cert_file=/etc/letsencrypt/live/example.com/fullchain.pem
smtpd_tls_key_file=/etc/letsencrypt/live/example.com/privkey.pem
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# MTA間TLSの設定
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_tls_security_level = may
smtp_tls_loglevel = 1
...
myhostname = mail.example.com
...
home_mailbox = Maildir追記: 「MTA 間 TLS の設定」を加えました(2018-09-18)
/etc/postfix/master.cf
... smtps inet n - y - - smtpd # -o syslog_name=postfix/smtps -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes # -o smtpd_reject_unlisted_recipient=no # -o smtpd_client_restrictions=$mua_client_restrictions # -o smtpd_helo_restrictions=$mua_helo_restrictions # -o smtpd_sender_restrictions=$mua_sender_restrictions # -o smtpd_recipient_restrictions= -o smtpd_relay_restrictions=permit_sasl_authenticated,reject # -o milter_macro_daemon_name=ORIGINATING ...
# systemctl restart postfix
Dovecot のインストール
POP3 は使わないので、IMAP だけインストールします。
# apt install dovecot-imapd
Dovecot の設定
こちらも元のファイルは残しておきしょう。
# cp /etc/dovecot/conf.d/10-master.conf /etc/dovecot/conf.d/10-master.conf.backup # cp /etc/dovecot/conf.d/10-ssl.conf /etc/dovecot/conf.d/10-ssl.conf.backup # cp /etc/dovecot/conf.d/10-mail.conf /etc/dovecot/conf.d/10-mail.conf.backup
/etc/dovecot/conf.d/10-mail.cf
... mail_location = maildir:~/Maildir ...
/etc/dovecot/conf.d/10-master.cf
...
inet_listener imaps {
    port = 993
    ssl = yes
}
...
# Postfix smtp-auth
    unix_listener /var/spool/postfix/private/auth {
    mode = 0666
}/etc/dovecot/conf.d/10-ssl.cf
... ssl = yes ... ssl_cert = </etc/letsencrypt/live/example.com/fullchain.pem ssl_key = </etc/letsencrypt/live/example.com/privkey.pem ...
# systemctl restart dovecot