Postfix SMTP認証 Ubuntu 18.04.1 2019/12

SASL2のインストール
apt-get install sasl2-bin

SMTP認証とサブミッションポートの使用
/etc/postfix/main.cf
# 末尾に追加
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions =
        permit_mynetworks
        permit_sasl_authenticated
        reject_unauth_destination

/etc/postfix/master.cf
SMTPポートではSMTP認証を使用しない。
smtp      inet  n       -       n       -       -       smtpd 
  -o smtpd_sasl_auth_enable=no
SUBMISSIONポートでSMTP認証を使用する。
submission inet n       -       n       -       -       smtpd
  -o smtpd_sasl_auth_enable=yes                               
* 行頭に#でないとコメントアウトにならず実行時にエラーとなるので注意。

認証方式の設定 /etc/postfix/sasl/smtpd.conf (新規作成)
pwcheck_method: auxprop
auxprop_plugin: sasldb
mech_list: cram-md5 digest-md5
pwcheck_methodにauxpropを使用すると、Postfixがsasldbを直接見に行く。SASLAuthデーモンは起動していなくてもよい。
CRAM-MD5はThundirbirdから接続する際は「暗号化されたパスワード」となる。

SMTP認証用のユーザを作成
# ユーザの作成
saslpasswd2 -f /var/spool/postfix/etc/sasldb2 -u (ドメインまたはホスト名) -c (ユーザ名)
# ユーザ一覧
sasldblistusers2 -f /var/spool/postfix/etc/sasldb2
# ユーザを削除する場合。
saslpasswd2 -f /var/spool/postfix/etc/sasldb2 -u (ドメインまたはホスト名) -d (ユーザ名)

データペースファイルの属性変更
chgrp postfix /var/spool/postfix/etc/sasldb2
chmod 640 /var/spool/postfix/etc/sasldb2
Postfixユーザが見れるように。

TLSをOFF
#smtpd_use_tls = yes
smtpd_use_tls = no

Postfixの再起動
systemctl restart postfix

クライアントPCのメーラーから接続し、メールの送信確認を行う。