PostfixからGmailへのメールリレー設定のメモ
Googleアカウントの管理画面からアプリパスワードを作成し取得します。
アプリパスワードをSASLパスワードDBに設定します。
[smtp.gmail.com]:587 username@gmail.com:sqirskhmgkcbvujw
※パスワードは仮のものです。
パスワード設定ファイルを作成します。
$ sudo postmap /etc/postfix/gmail $ ls -ltr /etc/postfix
gmail.dbが生成されたパスワードファイルです。
libsasl2-modulesを導入します。
$ apt install libsasl2-modules
/etc/postfix/main.cfにSASL設定などを追加します。
myhostname = mail.domain1.jp mydomain = domain1.jp relayhost = [smtp.gmail.com]:587 # Gmail relay smtp_sasl_auth_enable = yes smtp_sasl_mechanism_filter = plain smtp_sasl_password_maps = hash:/etc/postfix/gmail smtp_sasl_security_options = noanonymous smtp_sasl_tls_security_options = noanonymous smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt smtp_tls_security_level = encrypt smtp_use_tls = yes